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

pcall still shows error in console after function render?

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

1 answer

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)

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