#how can i create a limited quantity system?
1 messages · Page 1 of 1 (latest)
what have u tried
a limited quantity system
** You are now Level 1! **
** You are now Level 5! **
😭
ong
how do these ppl survive, even gpt cant work with this
they even try to create games bro 😭
just let me know if anyone knows or not to help my game THATS ALL
bc they kill themselves studying programming every day
chatgpt helps just enough
@halcyon nexus spare me bro
sorry bro
@halcyon nexus
local DataStoreService = game:GetService("DataStoreService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local StockData = DataStoreService:GetDataStore("WeaponStock_v1")
local WeaponFolder = ServerStorage:WaitForChild("LimitedWeapons")
local PurchaseRemote = Instance.new("RemoteFunction")
PurchaseRemote.Name = "PurchaseWeapon"
PurchaseRemote.Parent = ReplicatedStorage
PurchaseRemote.OnServerInvoke = function(player, weaponName)
local success, currentStock = pcall(function()
return StockData:GetAsync(weaponName)
end)
if success and currentStock and currentStock > 0 then
local weaponModel = WeaponFolder:FindFirstChild(weaponName)
if weaponModel then
local updateSuccess, newStock = pcall(function()
return StockData:UpdateAsync(weaponName, function(oldValue)
if oldValue and oldValue > 0 then
return oldValue - 1
end
return nil
end)
end)
if updateSuccess and newStock then
local tool = weaponModel:Clone()
tool.Parent = player.Backpack
return true, newStock
end
end
end
return false, 0
end
server script
i dont know how u want it