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

Is there a smoother way to build a boat?

Asked by 4 years ago

So I have a boat script here that works fine although isn't smooth. Sometimes the speed might glitch switching numbers really fast or the boat will float on nothing because of its body positions. Is there are way I can make boats smoother/better? This was a attempt.

seat = script.Parent
gyro = seat.BodyGyro
pos = seat.BodyPosition
vel = seat.BodyVelocity
pos.Position = seat.Position
gyro.CFrame = seat.CFrame
speed = 0
ready = true
wait()
seat.Anchored = false

function move(property)
    if property == "Steer" then
        if not ready then
            return
        end
        ready = false
        local steer = seat.Steer
        while steer ~= 0 do
            steer = seat.Steer
            if steer == 1 then
                gyro.CFrame = gyro.CFrame * CFrame.fromEulerAnglesXYZ(0,-.1,0)
            elseif steer == -1 then
                gyro.CFrame = gyro.CFrame * CFrame.fromEulerAnglesXYZ(0,.1,0)
            end
            wait()
            vel.Velocity = seat.CFrame.lookVector * speed
        end
        ready = true
    elseif property == "Throttle" then
        local throttle = seat.Throttle
        while throttle ~= 0 do
            if throttle == 1 and speed < seat.MaxSpeed then
                speed = speed + 1
            elseif throttle == -1 and speed > 0 then
                speed = speed - 1
            end
            wait()
            vel.Velocity = seat.CFrame.lookVector * speed
        end
    end
end

seat.Changed:Connect(move)

Answer this question