Win script fires more then once

For some reason, In test game, Avoid the evil teapots when you press the win pad, the Increase Intensity event runs like 3-6 times.

Im not sure How to fix this, my script is here:


local winEvent = game.ReplicatedStorage:WaitForChild("winMessage") //remote event to alert that somebody won


function onTouched(Obj)	 // when the winpart is touched
    Obj.parent.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(6, 5`, -10)) // teleport the player


if workspace.Intensity.Value ~= 9 then // increase the intensity of the teapots
	workspace.Intensity.Value += 1
end

winEvent:FireAllClients() // alert that somebody won
end

script.Parent.Touched:Connect(onTouched)
1 Like

its most likely that the player is touching the part more than once with different parts of there body, try adding a cool down or boolvalue so the player can only press it once X seconds

you have to debounce your script to stop it activating multiple times

is that all your code it doesnt look like it works? if not code you post the full code?
i can explain how to debounce (its just a big word that means to run something once then cool down before running again)

I think I made it work so thanks

1 Like