Im so scared to try this:
while wait(3) do end
Update: I want a loop to run for x amount of time, not delay running. I need it to run exactly x seconds before it becomes nil, and out of that timeframe it is nil.
To do this you IN ONE SERVER SCRIPT you will need a Bindable Event. If you are doing Server Script to Local Script (vice versa) you need to use Remote Event.
This is the code.
local BindableEvent = game.ReplicatedStorage.Event local length = 100 -- timer length local done = false -- will be true once the timer is done. local function timer() for time = length, 0, -1 do wait(1) end done = true end BindableEvent.Event:Connect(timer) BindableEvent:Fire() -- tells the BindableEvent.Event to connect/start the timer. repeat wait() -- your code here until done
Don't forget to create a bindable event in Replicated Storage.
So whats going on here? well the bindable event allows you to run two loops at once essentially, i.e. it creates different script threads. It also allows you to talk between server scripts.