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

How to find out if a certain string is bound to RenderStep?

So I'm using the function BindToRenderStep(name,priority,function()) and I'm wondering if there is a way to check if there is already a bound function under a certain name. As far as I'm aware, there isn't, but I'm just checking to make sure.

1 answer

✓ Accepted answer

I'm not aware of any methods built into RunService that can handle this, but creating function that can handle this for us shouldn't be a problem.


Here's what we'll need:

  • Dictionary table to store the keys we already used

  • Function that basically wraps BindToRenderStep so we don't have to manually add the key each time.

Here would be an example of the final product:

local RunService = game:GetService("RunService")
local Binded = {} -- Keys created

-- What we can use from now on
local function BindToRenderStep(key,pri,func)
	 -- Set the key to an existing value (this could actually come in handy for other tasks as well :P)
	Binded[key] = func

	-- The actual method
	RunService:BindToRenderStep(key,pri,func)
end

-- Example
BindToRenderStep("Test",Enum.RenderPriority.Camera,function()end)

-- Check if the key exists
if Binded["Test"] then
	print("There is already a function called Test binded to render step")
else
	print("No such key exists")
	BindToRenderStep("Test",Enum.RenderPriority.Camera,function()end)
end

Hope that helped, let me know if you have any questions.

1 comment

0

This gives me an idea of how I can adapt to my own script. The main problem is the fact that the scripts are all separated, but I think that can easily be bypassed with a bindable event. Thanks!

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