Hello, i am currently working on a game, and i would like to know how to make a script only run once. What i mean by that is i don't want to use debounce, since debounce is more of a timer for the script to then run again. I only want this, press a button, it runs the script, then you can't press it again, but the other players who haven't pressed the button yet can press it. Here is my code.
local water = script.Parent.Parent.Parent.water
local switch = script.Parent
function move(x, y ,z)
for i = 1,10 do
water.Position = water.Position + Vector3.new(x, y ,z)
wait(0.01)
end
end
function onClick()
switch.LaserFire:Play()
switch.BrickColor = BrickColor.new("Bright green")
switch.Size = Vector3.new(1, 0.211, 2.049)
move(-1.1,0,0)
return
end
script.Parent.ClickDetector.MouseClick:Connect(onClick)

1 comment
Thank you so much! I'll try to learn more about attributes. Thanks for your help! :D