I want to detect when a player sits in the driver seat and if that happens delete the folder the script is in Here is my script

seat = script.Parent.Parent
car = script.Parent.Parent.Parent
function onTouched(part)
while true do
wait(.1)
local h = part.Parent:FindFirstChild("Humanoid")
if (h.Sit == true) then
script.Parent:Destroy()
end
end
end

Sadly it didn't work It's not really needed to delete the folder I just want to stop the script when a player is on a seat Any help?

7 comments

0

Could you show me your explorer? Your explanation is making me confused.

0

Also, you do realize you need to run the function by command?

0

I'm not the best scripter so I'm just trying to find out what's wrong and hope I get a fix

0

The thing I need is if a player sits in the driver seat I want the script to destroy the folder it's in. Here is my explorer: https://gyazo.com/04942fc92e266bd38b7c7e4a7e6e79fd

0

There is a despawn script inside the folder too so I want the despawn script to be disabled or destroyed when someone sits on the seat

0

uh I already see the problem.

0

Ok well after adding an end to the script it still doesn't do what I need it to do