Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local item_folder = game.ReplicatedStorage.items -- get the folder
- local item1price = 50 -- item price
- local item2price = 50 -- item price
- game.Players.PlayerAdded:Connect(function(player) -- leader board set up
- local folder = Instance.new("Folder",player)
- folder.Name = "leaderstats"
- local coins = Instance.new("IntValue",folder)
- coins.Name = "Coins"
- coins.Value = 100
- end)
- game.ReplicatedStorage.buy.OnServerEvent:Connect(function(player, item) -- buy
- if item == "Sword" then -- item name
- local coins = tonumber(player.leaderstats.Coins.Value) -- get the coins
- if coins >= item1price then -- check if the player has enough money to buy the coins
- coins = coins - item1price -- minus the coins to the price
- local i = item_folder.ClassicSword:Clone() -- get & clone the sword
- i.Parent = player.Backpack -- place the sword to the players inventory
- player.leaderstats.Coins.Value = coins -- change the players coins
- end
- elseif item == "Lazer" then -- item name, 2nd item
- local coins = tonumber(player.leaderstats.Coins.Value) -- get the coins
- if coins >= item2price then -- check if the player has enough money to buy the coins
- coins = coins - item2price -- minus the coins to the price
- local i = item_folder.LaserGun:Clone() -- get & clone the gun
- i.Parent = player.Backpack -- place the sword to the players inventory
- player.leaderstats.Coins.Value = coins -- change the players coins
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment