I have this ClickDetector event, that connects to a function, that moves a part. However, when I press the button multiple times, the animation starts all over again. How would I make the ClickDetector work only once?
ClickDetector1.MouseClick:Connect(function() local Arrow2X = Arrow2.CFrame.X local OldArrow2X = Arrow2.CFrame.X local Arrow2TorsoY = Arrow2.CFrame.Y local Arrow2TorsoZ = Arrow2.CFrame.Z local Arrow2Ori = Arrow2.Orientation wait(4.25) if 2+2==4 then for i = 1,145,1 do Arrow2X = Arrow2X + 0.59 Arrow2.CFrame = CFrame.new(Arrow2X,Arrow2TorsoY,Arrow2TorsoZ) Arrow2.Orientation = Arrow2Ori wait(0.005) end for i = 1,10 do Arrow2.Transparency = Arrow2.Transparency + 0.1 wait(0.1) end end end)
Use the MaxActivationDistance property of the ClickDetector and set it to 0, doing this will make it impossible to click the detector and activate the function. Then, after however long the animation takes you can set it back to the default value.
ClickDetector1.MouseClick:Connect(function() ClickDetector1.MaxActivationDistance = 0 local Arrow2X = Arrow2.CFrame.X local OldArrow2X = Arrow2.CFrame.X local Arrow2TorsoY = Arrow2.CFrame.Y local Arrow2TorsoZ = Arrow2.CFrame.Z local Arrow2Ori = Arrow2.Orientation wait(4.25) if 2+2==4 then for i = 1,145,1 do Arrow2X = Arrow2X + 0.59 Arrow2.CFrame = CFrame.new(Arrow2X,Arrow2TorsoY,Arrow2TorsoZ) Arrow2.Orientation = Arrow2Ori wait(0.005) end for i = 1,10 do Arrow2.Transparency = Arrow2.Transparency + 0.1 wait(0.1) end end end)