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

Why did a module script in my game stop working when the script that required it was destroyed?

Asked by 5 years ago

I had a function in a module script that created and dropped ores for the dropper that was passed as the argument. Now a really funny thing happened. When I set the CanCollide of the part in which the main script was contained to false it fell through the world and was destroyed. But what is interesting is that the module script loop stopped running when that happened. Could someone explain why that was happening to me?

0
Note: I fixed the issue of the part falling by anchoring it. However, I wanted to find out why that weird bug was happening to me. User#21908 42 — 5y
0
can you include the script for the modulescript and the script? (click the three dots then edit) because i doubt that destroying a script would make any required scripts break fanofpixels 718 — 5y
0
You explained it yourself. You said the part was destroyed, and since it wasn't a valid member of Workspace, the loop did not run. TiredMelon 405 — 5y
0
I explained it sure but I wanted to better know how to use module scripts and avoid errors like this in the future User#21908 42 — 5y

1 answer

Log in to vote
1
Answered by
Z_DC 104
5 years ago

It probably happened due to the part's parent becoming nil after falling. When a script requires a module script it actually is still the main script running, so when it stops running, it stops running.

Ad

Answer this question