i want that the cars max speed changes if the car is driving on sand.
i have put a part underneath the car, its the part that checks the material the car is on.
Now its working but after a while it just doesn’t want to work anymore and the cars speed changes back to normal even though the car is still driving on sand.
Heres my script:
local part = script.Parent -- The material checker part local targetMaterial = Enum.Material.Sand -- the material it should detect local ChangeAttribute = script.Parent.Parent.Parent local function onTouch(hit) local partMaterial = part.Material if partMaterial == targetMaterial then ChangeAttribute:SetAttribute("MaxSpeed", 50) -- if material is sand change cars speed print("omg car is driving on sand lololol time to make car slower woooo") elseif not (partMaterial == targetMaterial) then ChangeAttribute:SetAttribute("MaxSpeed", 101.5) -- if its not sand then make the cars speed normal end end part.Touched:Connect(onTouch)
I would be very happy if someone helps me!