Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- game.Players.PlayerAdded:Connect(function(plr)
- local ls = Instance.new("Folder")
- ls.Name = "leaderstats"
- ls.Parent = plr
- local cash = Instance.new("IntValue")
- cash.Name = "Cash"
- cash.Value = 1200
- cash.Parent = ls
- end)
- local itemBoughtRE = game.ReplicatedStorage:WaitForChild("OnItemBought")
- itemBoughtRE.OnServerEvent:Connect(function(plr, itemBuying)
- local char = plr.Character or plr.CharacterAdded:Wait()
- if plr.Backpack:FindFirstChild(itemBuying.Name) or char:FindFirstChild(itemBuying.Name) then return end
- if plr.leaderstats.Cash.Value < itemBuying.Price.Value then return end
- plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value - itemBuying.Price.Value
- game.ReplicatedStorage.BuyableItems[itemBuying.Name]:Clone().Parent = plr.Backpack
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement