How can I make the game tell that I already have the item in my backpack so it doesn't repeat its purchase?
local price = script.Parent.Parent.Price local tools = game.ReplicatedStorage:WaitForChild("Tools") local tool = script.Parent.Parent.ItemName local player = script.Parent.Parent.Parent.Parent.Parent.Parent script.Parent.MouseButton1Click:Connect(function() if player.leaderstats:FindFirstChild("Cash").Value >= price.Value then player.leaderstats:FindFirstChild("Cash").Value = player.leaderstats:FindFirstChild("Cash").Value - price.Value game.ReplicatedStorage.ShopBuy:FireServer(tool.Value) end end)
Hello, fr2013!
I'm assuming that tool.Name
is the item name
local price = script.Parent.Parent.Price local tools = game.ReplicatedStorage:WaitForChild("Tools") local tool = script.Parent.Parent.ItemName local player = script.Parent.Parent.Parent.Parent.Parent.Parent script.Parent.MouseButton1Click:Connect(function() if player.Character:FindFirstChild(tool.Name) or player.Backpack:FindFirstChild(tool.Name) then return end --Returns if player is holding (or have on the backpack) the tool name (tool.Value) if player.leaderstats:FindFirstChild("Cash").Value >= price.Value then player.leaderstats:FindFirstChild("Cash").Value = player.leaderstats:FindFirstChild("Cash").Value - price.Value game.ReplicatedStorage.ShopBuy:FireServer(tool.Value) end end)
Good Luck with your games