local debounce = true
game.Players.PlayerAdded:Connect(function(player)
local Players = game:GetService("Players")
local clickdetector = game.Workspace.TestClick.ClickDetector
clickdetector.MouseClick:Connect(function(player2)
script.Parent.Touched:connect(function(hit) --Activates when hit
if hit.Name == "Orange" then
if debounce then
debounce = false
local cool = player.Name
print(cool)
local leader = player2.leaderstats.Gold
hit:Destroy()
leader.Value = leader.Value + 50
wait(1)
debounce = true
end
end
end)
end)
end)
This is supposed to check when the user clicks the part if a part named orange is touching the part this script is attached too. It works, but if you click the part it continues to check if "Orange" is inside of it forever instead of only when the part is clicked. Also It wont detect if anything is in it unless something, whether a player of part, is moving in it

2 comments
If both the clickable part and the "Orange" part aren't moving when you click it won't fire anything for touched.
how do I fix that