I want to make item, buyable from the button, that gives you only one tool, that you must to buy for money, and after tool has appeared in your inventory, you can't buy another same tool per your server rejoining.
Code: local Item = script.Parent.Item --Gun local Price = script.Parent.Price -- 200 local Currency = script.Parent.Currency --Money local Debounce = true
script.Parent.Touched:Connect(function(Hit)
local Player = game:GetService("Players"):GetPlayerFromCharacter(Hit.Parent)
if Player and Debounce == true and not Player:WaitForChild("Backpack"):FindFirstChild(Item.Name) then
Debounce = false
script.Connect(function(player)
local CurrencyName = player.leaderstats:FindFirstChild(Currency.Value)
local ItemName = game.ReplicatedStorage:FindFirstChild(Item.Value)
if CurrencyName.Value >=Price.Value then
CurrencyName.Value = CurrencyName.Value - Price.Value
ItemName:Clone().Parent = player.StarterGear
ItemName:Clone().Parent = player.Backpack
end end) end end) .
