Localscript seemingly running even while parented to seemingly nothing after its parent gets destroyed?

hi, i’ve had this issue going on for a while, it’s not game breaking but it’s very very confusing

basically, i have this script in my game that lets you freeze your car in place at the click of a key input (UserInputService KeyDown), however one thing that started happening after i switched from the legacy mouse.KeyDown method for inputs was that the script appeared to error if you tried to freeze your car after already having spawned others prior, which was very confusing, as the script is always held inside of a screengui that you only ever have when you’re inside the car, and it (the screengui) gets destroyed whenever you get out.

i added a :GetFullName() print to see if i could find out where the hell the script is running from, because the green censors are a car that isn’t even spawned anymore, yet for some reason the script that belonged to it still lives on terrorizing me with these errors - only to realize that the script is just running from nothing, it returns its FullName as just its own name, as opposed to being stored elsewhere like playergui for example. The reason why the script can’t find the DriveSeat is because the car has already been deleted, yet for some reason the script keeps living on for reasons i can’t even think of

I’m pretty sure this is the only script with this issue, as i feel like i’d be getting a lot more errors than just this if every script was like this - not to mention that i believe these errors even affect the currently running iteration of the script belonging to your currently spawned car

that’s really all i have, i’m just taking a shot in the dark hoping that maybe someone knows why this could possibly be happening, as i’ve given up on reason a long while ago

scripts keep running after the parent is destroyed if they have a reference to themselves stored

could you give an example for this ?

Try starting out with the Driver script disabled, then key of the seat to enable it. When they exit disabled the drivers script again.

Heya! I don’t know the core issue, it’d be helpful to see what line 16 and line 55 are. However you could do a simple

if not Model or not Model:FindFirstChild("DriveSeat") then
	return
end

before the erroring lines, just a thought! And i know i responded many days too late but it should fix it!

local script = script;
script:Destroy();

print("this script is running!")