I’m trying to rescript a boat script that uses body forces so that it floats in water, however anytime that I try and swap out body forces that allow the boat to interact with terrain water, the entire script breaks, this only happens when I change a body gyro for a body angular velocity so that I can steer, that the body velocity breaks and I’m unable to move or turn, swapping the body velocity works fine on its own. I’m not very experienced in programming so any help is welcome.
Here’s the original code
script.Parent.MaxSpeed = script.Parent.Settings.MaxSpeed.Value
maxspeed = script.Parent.MaxSpeed
script.Parent.BodyPosition.position = script.Parent.Position
script.Parent.BodyGyro.cframe = script.Parent.CFrame
value1 = 0
while true do
wait()
if script.Parent.Throttle == 1 then
if value1 < maxspeed then value1 = value1 + script.Parent.Settings.Acceleration.Value end
script.Parent.Driving.Value = true
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Throttle == 0 then
script.Parent.Driving.Value = false
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Throttle == -1 then
if value1 > - maxspeed then value1 = value1 -script.Parent.Settings.Acceleration.Value end
script.Parent.Driving.Value = true
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Steer == 1 then
script.Parent.BodyGyro.cframe = script.Parent.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,- script.Parent.Settings.TurnSpeed.Value,0)
script.Parent.Driving.Value = true
script.Parent.Right.Value = true
script.Parent.Left.Value = false
end
if script.Parent.Steer == -1 then
script.Parent.BodyGyro.cframe = script.Parent.BodyGyro.cframe * CFrame.fromEulerAnglesXYZ(0,script.Parent.Settings.TurnSpeed.Value,0)
script.Parent.Driving.Value = true
script.Parent.Left.Value = true
script.Parent.Right.Value = false
end
end
And here is my code
script.Parent.MaxSpeed = script.Parent.Settings.MaxSpeed.Value
maxspeed = script.Parent.MaxSpeed
script.Parent.BodyAngularVelocity.AngularVelocity = script.Parent.CFrame
value1 = 0
while true do
wait()
if script.Parent.Throttle == 1 then
if value1 < maxspeed then value1 = value1 + script.Parent.Settings.Acceleration.Value end
script.Parent.Driving.Value = true
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Throttle == 0 then
script.Parent.Driving.Value = false
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Throttle == -1 then
if value1 > - maxspeed then value1 = value1 -script.Parent.Settings.Acceleration.Value end
script.Parent.Driving.Value = true
script.Parent.BodyVelocity.velocity = script.Parent.CFrame.lookVector*value1
script.Parent.Left.Value = false
script.Parent.Right.Value = false
end
if script.Parent.Steer == 1 then
script.Parent.BodyAngularVelocity.AngularVelocity = script.Parent.BodyAngularVelocity.AngularVelocity * CFrame.fromEulerAnglesXYZ(0,- script.Parent.Settings.TurnSpeed.Value,0)
script.Parent.Driving.Value = true
script.Parent.Right.Value = true
script.Parent.Left.Value = false
end
if script.Parent.Steer == -1 then
script.Parent.BodyAngularVelocity.AngularVelocity = script.Parent.BodyAngularVelocity.AngularVelocity * CFrame.fromEulerAnglesXYZ(0,script.Parent.Settings.TurnSpeed.Value,0)
script.Parent.Driving.Value = true
script.Parent.Left.Value = true
script.Parent.Right.Value = false
end
end