I have a shop and it works fine but I want to change that when someone buys a tool, they cannot buy that tool again as long as they have that tool.
Here is the script:
local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("BuyTool") local function buyTool(player, tool) if player.leaderstats["????"].Value >= tool.Price.Value then player.leaderstats["????"].Value = player.leaderstats["????"].Value - tool.Price.Value local giveTool = ReplicatedStorage.ShopItems[tool.Name]:Clone() giveTool.Parent = player.Backpack local giveTool = ReplicatedStorage.ShopItems[tool.Name]:Clone() giveTool.Parent = player.StarterGear end end remoteEvent.OnServerEvent:Connect(buyTool)
Check if the player already has an item in their inventory,
function buy(plr,tool) if player.StarterGear:FindFirstChild(tool.Name) == false then --do your code here! end
Or something along those lines