When I click the button to buy a sword, it doesn't say any errors or give me the sword.
script.Parent.MouseButton1Click:Connect(function() game.Players.PlayerAdded:Connect(function(plr) local RS = game:WaitForChild("ReplicatedStorage") local library = RS:WaitForChild("Library") local tool = library.ClassicSword if plr.leaderstats.Cash.Value >= 1 then print("enough") local clone = tool:Clone() clone.Parent = plr.Backpack elseif plr.leaderstats.Cash.Value < 1 then print("not enough") end end) end)
You are creating an event listener for when the Mousebutton1Click fires. Then each time that fires you create a new listener for when player joins.
I think you are trying to get something like this
local plr = game.Players.LocalPlayer script.Parent.MouseButton1Click:Connect(function() local RS = game:WaitForChild("ReplicatedStorage") local library = RS:WaitForChild("Library") local tool = library.ClassicSword if plr.leaderstats.Cash.Value >= 1 then print("enough") local clone = tool:Clone() clone.Parent = plr.Backpack elseif plr.leaderstats.Cash.Value < 1 then print("not enough") end end)