Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I stop a RenderStepped loop from running?

Asked by 5 years ago

I'm working on a door transition script that fads a black gui using renderstepped, but it has to fire an event afterwards to teleport a player, but I don't want it to keep doing that.

local doorTransition = game.ReplicatedStorage.Remote.ServerToClient.Event.DoorTransition

doorTransition.OnClientEvent:Connect(function(plr)

    print("Recieved from server")

    --////Fancy transitioning
    local runService = game:GetService("RunService")

    runService.RenderStepped:Connect(function()


        script.Parent.BackgroundTransparency = script.Parent.BackgroundTransparency - 0.025

        if script.Parent.BackgroundTransparency <= 0 then



        end


    end)

end)

2 answers

Log in to vote
1
Answered by 5 years ago

It would be best to use what Roblox provides you with. BindToRenderStep and UnbindFromRenderStep.

local runServ = game:GetService("RunService")

runServ:BindToRenderStep("test", Enum.RenderPriority.Camera.Value, function() print("ran") end)

wait(2)

runServ:UnbindFromRenderStep("test")

Hope this helps.

Ad
Log in to vote
0
Answered by 5 years ago

Example from Locard:

local runService = game:GetService('RunService')
local Stepped
Stepped = runService.Stepped:Connect(function()
    print('Printing')
end)

wait(.5)
Stepped:Disconnect()

Answer this question