Using wait in a plugin properly

With plugin UI, I want to add a wait command but if you close the ui before it ends it errors out, any help?

if owns == true then
			pluginui.MainUI.Loading.Visible = true
			task.wait(2)
			pluginui.MainUI.Editor.Visible = true
		else
			pluginui.MainUI.PurchaseScreen.Visible = true
		end

for local script u can try this, if u have any errors with this script u can reply it

local function showEditor(pluginui)
	if owns then
		pluginui.MainUI.Loading.Visible = true
		wait(2)
		pluginui.MainUI.Editor.Visible = true
	else
		pluginui.MainUI.PurchaseScreen.Visible = true
	end
end

showEditor(pluginui)

I managed to fix it with hiding the ui instead of deleting it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.