I have noticed the motors in the screenshots below still functioned after the script was destroyed and was checking with some prints to find out what caused this, But instead i saw that the script still functioned after being destroyed.
On the server it says its destroyed.
Same thing for the player.
The destroying function (on the local script) :
if Block.Configuration[“Powered”].Value == false then
Motor.ActuatorType = None
Motor.LimitsEnabled = false
print(Destroyed)
wait()
script:Destroy()
print(scriptwasdestroyed)
end
The local script is inside of the block that was cloned by a serversided script to workspace and the local script is moved by a script on the server to a folder in the character and then enabled.
and whenever powered is turned off the script destroys itself.
after being destroyed it prints nil as its parent.
Does anyone know why this occurs? And what do i do to prevent this from happening?
This could be because you’re not disabling the script with BaseScript.Disabled, just destroying it. All calling Instance:Destroy does is parent the Instance to nil, lock the parent property, and disconnect all connections.
Scripts which have been destroyed, parented to nil, etc will continue running. I do not believe that .Disabled will help but I haven’t tested if scripts do disable after running. If you want to stop your script make sure you disconnect all events and break any loops.
No not normally… I’d think that that would be very hard to implement since Roblox would have to somehow kill every thread attached to the script. Some games actually rely on this to help hide their scripts from exploiters.
No… You can parent the script to somewhere hard to access by exploiters. The code still has to be visible to the client though otherwise it couldn’t run.
Destroying the script on the client does not destroy it on the server. Place the LocalScript inside ServerStorage to prevent the client accessing it (AFAIK)
Whenever the value “powered” is turned off the script should destroy itself getting rid of any function which is still running or to prevent it from going any further, Basically less lag.