I'm making a simulator and for the shop, I had a bug where if you already had the tool you would not get it, But there is a saving tool, So when I rejoin I can buy the item again, I wrote some code and now it doesn't work anymore, Can anyone help me?
Here's my code:
player = script.Parent.Parent.Parent.Parent.Parent.Parent
bucks = player.leaderstats.Bucks
price = 25
tool = game:GetService("ReplicatedStorage"):FindFirstChild("Woods"):FindFirstChild("AmericaWood")
infoFrame = script.Parent.Parent
function buy()
if bucks.Value >= price then
if not player:FindFirstChild(tool) then
script.Disabled = true
else
bucks.Value = bucks.Value - price
local clone = tool:Clone()
clone.Parent = player.Backpack
local clone2 = tool:Clone()
clone2.Parent = player.StarterGear
player:WaitForChild("Backpack"):FindFirstChild("Wood"):Destroy()
script.Disabled = true
end
end
end
script.Parent.MouseButton1Click:Connect(buy)
If anyone could help, Please help me, Thank you!

3 comments
is the whole thing in a server script
if it is it'll not work, if I remember correctly MouseButton1Click doesn't fire on a server sided script
Omg thank you so much, You saved my time!