I am attempting to make a car anti-theft so people cant steal it. I have to use a onTouched to make it work but it messes up other code parented into the seat

heres the code:

local seat = script.Parent

local car = seat.Parent

local carowner = seat.CarOwner

  

function onTouched(part)

if part.Name == "Left Leg" then

local h = part.Parent:FindFirstChild("Humanoid")

if (h ~= nil) then

carowner.Value = h.Parent.Name

end

end

end

  

  

script.Parent.Touched:connect(onTouched)

6 comments

0

I don't see any problems here. What script is not working because of this?

0

its just another script in the vehicle seat. the other one doesnt even have a onTouched in it!

0

its a OnTouched script, meaning its mostly likely to block (mask) other scripts, or run its script 1st.

0

ah. that makes sense

0

Use a debounce system as it is probably due to overflowing

0

yeah that was the problem gg