Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I stop a RenderStepped service in a function?

RS.RenderStepped:Connect(function()
	print(math.floor((plr.Position - item.Position).Magnitude))
	if (plr.Position - item.Position).Magnitude < 7.5 then
		print("yes")
		GUI:FireServer()
	end
end)

I'm trying to make a BillboardGui appear with TweenService when a player walks near it, but I'm using RenderStepped for this case.

Do I need to change the function to a while loop? Thanks! -Zlurm

1 answer

Hi. You can make a variable storing the function, the disconnect it after.

local Connection
Connection = RS.RenderStepped:Connect(function()
— Code here
end)
Connection:Disconnect()

Hope this helps

2 comments

0

You have to put it the Disconnect inside the function.

0

I thought you can put it anywhere? Be it inside the function or outside, no??

This discussion is preserved as it was. New answers, comments, and votes are closed.