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

Xpcall spamming output and handling function? [ANS]

I was playing around with xpcall and it seems to spam my output and spam the handle erroring function all while messing up the rest of my script below it, (it's not in a while true do or anything)

(this only happens when something errors)

local startingtheme = "bad" --Isn't a member of what it's checking so it will error

function handleError(message)
	local err = script.Parent.Examples.ErrorFrame:Clone()
	err.Parent = script.Parent.MenuFrame
	err.Position = UDim2.new(.3,0,-1,0)
	err.Msg.Text = "Error: " .. message:gsub("(.-:)","")
	err.Visible = true
	wait(.1)
	err:TweenPosition(UDim2.new(.3,0,.3,0),"Out","Sine",.2,false)
	wait(5)
	err:TweenPosition(UDim2.new(.3,0,-1,0),"Out","Sine",.2,false)
	wait(.2)
	err:Destroy()
end

function setuptheme()
	script.Parent.MenuFrame.Settings.StyleFrame.DesignFrame.Display[startingtheme].BorderSizePixel = 3
end

xpcall(setuptheme,handleError)

gettings spammed with: "cannot resume non-suspended coroutine" with no line or anything, just that

EDIT I tried to print the message it was handling and it printed 'attempt to yield across metamethod/C-call boundary'

1 answer

ANSWER: You can't have a delay in the error handling function hence the 'attempt to yield across' part of the erroring message

SOLUTION: make a spawn(function() to cancel out the yielding of the xpcall

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