Hey,
I notice that whenever i click on a part that has a clickdetector (specificly right click) it sometimes fires twice event three times.
Here is the code i whrote:
local debounce = false
script.Parent.ClickDetector.RightMouseClick:Connect(function(player)
print("Left Clicked")
local Side = player:WaitForChild("Side")
if debounce == false then
if Side.Ghoul.Value == true then
debounce = true
local GhoulData = player:WaitForChild("GhoulData")
local StatPoints = GhoulData:WaitForChild("StatPoints")
StatPoints.Value += 100
else
debounce = true
local CCGData = player:WaitForChild("CCGData")
local StatPoints = CCGData:WaitForChild("StatPoints")
StatPoints.Value += 100
end
delay(0.1, function()
debounce = false
end)
end
end)
Here you can see what the console gives me when i right click the part:
I know that my script works because i added a debounce but i whould like to know why is that happening, Also take a note that the script is running from a server script inside the part.
I also tested in a Client script and it does the same.
Any suggestion whould be greatly appreciated!