local button = script.Parent local elevator = button.Parent.Elevatorpiece local ecf = elevator.Position function onClicked(plr) print("elevator started") wait(2) for i = 1,52 do elevator.Position = elevator.Position + Vector3.new (0,.5,0) wait(.01) end end
Hey macabe55101,
function do_something(x, y) -- Declaring a function with x and y paramters (They are numbers) print(x + y) -- Printing x + y script.Disabled = true -- Disabling the script so it won't work unless this is set to false end do_something(2, 5) -- Calling the function(Prints 7 and then gets script disabled.
~~ KingLoneCat
If you do not want to completely disable your script, then there is another alternative method. Assuming that you are connected to a click event, you could simply disconnect the click event.
local button = script.Parent local elevator = button.Parent.Elevatorpiece local ecf = elevator.Position local onclick; onclick = button.Click:connect(function() print("elevator started") wait(2) for i = 1,52 do elevator.Position = elevator.Position + Vector3.new (0,.5,0) wait(.01) end onclick:disconnect(); end);
The onclick variable must be declared before assigning it like in this example so that when you get to the line where is disconnects it does not reference a variable that does not exist.