Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I fix my global function?

Asked by 10 years ago

Ok so I have a global function in a LocalScript called _G.Destroy() that basically destroys an object after a set time has passed. But for some reason, whenever the script it was called from is disabled or destroyed, the object will not be deleted. I don't know what is causing it. I will include some code:

_G.Destroy = function(Obj,Time)
    delay(Time,function()
        Obj:Destroy()
    end)
end

I have a script that deletes a brick after 10 seconds, and when I disable the script after 5 seconds have passed, the brick does not get deleted even thought the function has been called. However, when I don't disable the script and it waits 10 seconds, it deletes the brick. The deleting part of the script looks like this:

_G.Destroy(game.Workspace.Brick,10)

Please help!

0
Because, just Destroying or Disabling the script pauses or stops the script, the script will be in Stand-by mode or will not go on until it is added again, or enabled again. TheeDeathCaster 2368 — 10y
0
So disabling a script affects global functions as well? TurboFusion 1821 — 10y

Answer this question