My friends and I are making a demolition derby game and we can't figure out this one script. We're trying to make it so if the vehicle goes over a certain speed, it crashes. Example: If your car goes 1 MPH and hits another car only going 1 MPH the other car wouldn't take any damage.
seat = script.Parent.Parent.VehicleSeat speed = seat.Velocity.magnitude
if speed >= 100 then crash = true end
if crash == true then end function onTouched(Part) Part:BreakJoints() end script.Parent.Touched:connect(onTouched)
I'm going to assume that you are new at scripting or it just pasted weirdly(which happens to often). There are several basic errors that ruin the script but you had the right idea, here is what your script should look like based off of this:
seat = script.Parent.Parent.VehicleSeat speed = seat.Velocity.Magnitude if speed >= 100 then crash = true end if crash == true then Part:BreakJoints() end
I'm not sure why onTouched was used so much, unless is was some function that needed to be constantly called but if you made a variable to the car then you could break its joints like so:
(VariableForCar):BreakJoints()