The RunService:UnbindFromRenderStep function code samples are both broken due to incorrectly using the pcall function.
The issue lies on line 3 of the first code sample and line 12 of the second.
local success, message = pcall(RunService:UnbindFromRenderStep("binded name"))
Error
To fix this, make sure to wrap pcall around a function. Example:
local success, message = pcall(function() RunService:UnbindFromRenderStep("binded name") end)
I’ve re-written both samples to correctly work.
Sample 1
local RunService = game:GetService("RunService")
local Success, Message = pcall(function() RunService:UnbindFromtRenderStep("drawImage") end)
if Success then
print("Success: Function unbound!")
else
print("An error occurred: " .. Message)
end
Sample 2
local RunService = game:GetService("RunService")
-- Step 1: Declare the function
function printHello()
print("Hello")
end
-- Step 2: Bind the function
RunService:BindToRenderStep("Print Hello", Enum.RenderPriority.First.Value, printHello)
-- Step 3: Unbind the function
local Success, Message = pcall(function() RunService:UnbindFromRenderStep("Print Hello") end)
if Success then -- if the function was unbound
print("Success: Function unbound!")
else -- if it wasn't
print("An error occurred: " .. Message)
end
Additionally there is a spelling mistake in the description, misspelling "every" as "ever".
should be
context:
Given a name of a function sent to
RunService:BindToRenderStep
, this method will unbind the function from being called during RenderStepped. This is used to unbind bound functions once they are no longer needed, or when they no longer need to fire ever step .