0

pcall still shows error in console after function render?

TechModel 118
15 days ago
Edited 15 days ago

I have a local function running when objects are present in the workspace, but then gives me error even with pcall? Do I put the pcall inside the local function or outside to not get the error?

local function Spawns()
local c
c = game:GetService("RunService").RenderStepped:Connect(function()
if workspace.Model then -- doesnt exist but gives error
-- something
end
end)
end
local s, e = pcall(coroutine.wrap(Spawns)())
if not s then
print(e)
end


0

if pcall is needed for the rest of the script, then you should probably add back but pretty sure using findfirstchild will make it so that it won't error if nothing is there

function Spawns()
local c; c = game:GetService("RunService").RenderStepped:Connect(function()
local model = workspace:FindFirstChild('Model')
if model then
-- something

c:Disconnect()
end
end)
end

delay(1,function()
Spawns()
end)