I’m at a bit of a block here. I want to insert a string into a table, but the code won’t run if the script is destroyed. Is there a way to make this happen even if the script is destroyed?
Example script
local ObjectNames = {} -- Table that contains object names.
function InsertName(Name: string)
task.wait(2) -- waits 2 seconds obviously.
table.insert(ObjectNames, Name) -- inserts the object name into the "ObjectNames" table
end
local Task = coroutine.create(InsertName) -- creates a coroutine (coroutines are used to make code run without delaying the script)
coroutine.resume(Task) -- makes the coroutine run.
script:Destroy() -- destroys the script, but the coroutine won't run, because the script was destroyed.
Have a different script Destroy() that script. May not work however as you made this a coroutine.
Maybe set up a break point in that. if x=true then break end