On line 13 of the Caller script, it is supposed to go to the SteppedModule and do RunsService:BindToRenderStep() and line 15 to unbind after waiting 5 seconds. The function passed on is supposed to create parts into workspace.
The problem is that on Run mode it works fine, but on Play, no parts are being created.
Replacing the
with on the SteppedModule and it prints fine. I’ve spent about an hour trying to rearrange the code but it still only creates parts on Run. Any reason why?
The only real alternative is using the events that run on the server, at least RunService.Heartbeat. RunService.RenderStepped will definitely not fire, and I don’t know about RunService.Stepped, but it most likely will.
You can achieve a similar workflow to RunService:BindToRenderStep by calling a table of functions each frame on one of its events:
local OnStep = {}
game:GetService("RunService").Heartbeat:Connect(function(dt)
for _,fn in ipairs(OnStep) do
fn(dt)
end
end)
table.insert(OnStep,function()
Instance.new("Part",workspace)
end)
local index = #OnStep
wait(5)
table.remove(OnStep,index)
Stepped and Heartbeat both fire on the server and it’s a choice of whether you want to run your code before or after the Physics step. Heartbeat is the safe option usually.
For OP:
Replace :BindToRenderStep(self.tag, self.prior, self.func) with .Heartbeat:Connect(self.func)
To “unbind” it, you’ll need to store the result, and then call :Disconnect() on it in your unbind function.