I have a script that is parented to an actor which is a projectile from a weapon. Part of the script is when the projectile touches something, a series of effects are generated.
The problem is that last line. When I remove the actor (model) from the workspace, the script stops executing. It’s not a destroy, but a reparent. The Explosion.Hit event won’t fire and the Tween:Completed event won’t fire either. This part of the script will execute only once.
My understanding is that server scripts will execute no matter what their parent is.
Any ideas on how to get around this?
EDIT:
After some more testing, I discovered that the issue isn’t when the Actor.Parent is set to nil, the problem manifests when Actor.Parent is changed at all. Even when changing the parent to something like ReplicatedStorage it fails. This is looking more like a bug.
If you parent the Model to nil, you essentially remove it from the game, but the Model is still in the memory as in hasn’t been destroyed. But if you remove the Model you also remove the script inside and it won’t execute until you give the Model a parent again. Once you reparent the Model that was previously parented to nil, it’s like you just created a new instance and the script will begin it’s execution from the start.
I edited my original post to include new information. I changed the parent to game.ReplicatedStorage and the problem still happens. Now I have parented scripts before and they still ran, but I can’t do this because of the actor as the script is potentially in a different VM and it executes from the start. This is looking more and more like a bug.
Ok, I can try to place it in game.ServerScriptService then.
EDIT:
That’s what it was. It will still execute in ServerScriptService. Roblox needs a top level place to put items where they still need to execute but they are out of the workspace.