So I'm making a self driving car which I want to stop when it touches a player's car, the script works but when it touches a model that's not a player's car it drops like 20 errors and lags for a bit. The error is: "Momo is not a valid member of Model"
And here's the code:
script.Parent.Touched:connect(function(hit)
script.Parent.TouchEnded:Connect(function(hit2)
local ab = hit.Parent
local cd = hit.Parent.Momo
if ab and cd then
print("Stahp!!!")
script.Parent.Parent.Parent.Chassis.stop.Value = true
script.Disabled = true
wait(2)
if hit2.Parent.Momo then
script.Parent.Parent.Parent.Chassis.stop.Value = false
print("Go.")
script.Disabled = false
wait(2)
end
end
end)
end)

1 comment
That worked, thanks!