I was trying to make a boat system but got stuck with even moving it forward/backward and also having a problem with it flipping over
Server Script:
local Boat = script.Parent
local VehicleSeat = Boat.VehicleSeat
local AlignPos = Boat.PrimaryPart.AlignPosition
VehicleSeat:GetPropertyChangedSignal("Throttle"):Connect(function()
local x = AlignPos.Position.X
local y = AlignPos.Position.Y
local z = AlignPos.Position.Z
AlignPos.Position = Vector3.new(
x,
y,
z * -VehicleSeat.Throttle * 0.5
)
end)
Model:

Problem
- It moves forward but how can i do it for backwards too?
- flips boat if the player jumps on the edge of the boat
- Only goes in one direction and doesnât stop until it reaches its destination
2 Likes
There are so many posts about boats already. Try the Search button up top.
Are you using Terrain Water? Iâve got quite a few solutions on boat topics that Iâve posted on to keep the boat from flipping.
If you arenât using Water then you need an AlignOrientation to keep it level. You can also use it to steer the boat.
1 Like
Donât multiply Throttle with z because if Throttle becomes zero â it literally makes z go to 0 (which explains why it just âgoes forwardâ)
Do addition instead.
AlignPos.Position = Vector3.new(
x,
y,
z + (-VehicleSeat.Throttle * 5)
)
Also, just put the script in the seat and use vehicleSeat = script.Parent
.
Itâs a good idea to not use actual names of items as Variable names. Just make the capital letter a small case letter.
yeah i already figured that out but thank you
I did theres none that helped me
You didnât answer my Terrain/not Terrain question though.
no its not terrain its custom water/just a part
I searched âboat on Part waterâ, âboat using Part waterâ, âboat floating on Partâ, and found quite a few posts that may help.
1 Like
send them if you think they might help
You can search them too. Some have solved checkmarks so look at them first.
Honestly Iâd just rewrite the code its messy and rather complicated. My version, where the AlignPosition continues to use OneAttachment
local seat = script.Parent -- Script is in vehicle seat
local boat = seat.Parent.PrimaryPart -- Boat model's main part
local ap = boat.AlignPosition -- Align position which is connected to a attachment in the boat's main part
local isholding; local speed = 10
seat:GetPropertyChangedSignal("ThrottleFloat"):Connect(function() -- Throttle is deprecated
local tf = seat.ThrottleFloat
if tf == 0 then isholding = false else isholding = true end
while isholding do
ap.Position = boat.Position + boat.CFrame.LookVector * speed * tf
task.wait()
end
end)
Basically the code operates in a while loop that runs only when the player is holding either movement key. The align position will move parallel to the direction its facing ,speed
studs, with tf determining whether it should move forward or back (its either 1 or -1). If the player stops holding (tf = 0), the flag will be false so theyâll stop moving. The same logic can be used for steering
thank you also i did not know throttle was deprecated