Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why wont this work???

Asked by 7 years ago
Edited 7 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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)

1 answer

Log in to vote
0
Answered by 7 years ago

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()

Ad

Answer this question