I'm new to scripting. How do you connect to the player clicking?

I'm trying to remove the package from the player then add 1000. I don't know the right way to write this code.

local money = game.Players.LocalPlayer.leaderstats.Money



script.Parent.ClickDetector.MouseClick:Connect(function(player)
	

player.Backpack:findFirstChild("Package1"):remove()

money.Value = money.Value + 1000


script.Parent.ClickDetector.MaxActivationDistance = 0

wait(30)

script.Parent.ClickDetector.MaxActivationDistance = 32

end)

2 comments

0

May I ask, are you using the term "Button" as in a part, or a GUI?

0

There is no function :remove() , you need to use :Destroy()