Boat wont stay upright / out of control

My jetski boat won’t stay upright and when you drive forward it goes sideways and spins in circles, same with reverse.

Here is the model, and the code, along with a video demonstrating what happens, not sure what I should do right now, any ideas?

--[[SERVICES]]--
local collectionService = game:GetService("CollectionService")
local runService = game:GetService("RunService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local serverStorage = game:GetService("ServerStorage")

local function whileWaitLoop(boat, raycastParams)
	runService.Heartbeat:Connect(function()
		local startingPos = boat.VehicleSeat.Position + Vector3.new(0, 5, 0)
		local endingPos = boat.VehicleSeat.Position - Vector3.new(0, 15, 0)
		local ray = workspace:Raycast(startingPos, endingPos - startingPos, raycastParams)

		if ray and ray.Material == Enum.Material.Water then
			boat.AngularVelocity.Enabled = true
			boat.LinearVelocity.Enabled = true
		else
			boat.AngularVelocity.Enabled = false
			boat.LinearVelocity.Enabled = false
		end
	end)
end

local function boatStuff(boat)
	local speedValue = boat.SpeedValue
	local driversSeat = boat.VehicleSeat
	local raycastParams = RaycastParams.new()

	raycastParams.FilterDescendantsInstances = {workspace.Terrain}
	raycastParams.FilterType = Enum.RaycastFilterType.Whitelist

	driversSeat.Changed:Connect(function()
		boat.AngularVelocity.AngularVelocity = Vector3.new(0, -1 * driversSeat.Steer, 0)
		boat.LinearVelocity.LineVelocity = speedValue.Value * driversSeat.Throttle
	end)
	whileWaitLoop(boat, raycastParams)
end

for _, boat in pairs(collectionService:GetTagged("Boat")) do
	boatStuff(boat)
end

collectionService:GetInstanceAddedSignal("Boat"):Connect(function(instance)
	boatStuff(instance)
end)

The video is here: Imgur: The magic of the Internet

Any help would be much appreciated :smiley:

Hi,
Have you fiddled around with AlignOrientation, so it tries to keep a upright orientation?

no I haven’t. do you think you could point me in the right direction on how I’d use it to keep the boat up?

I would have a invisible part, that works as the “uprightPart”, and then have the boat try to alogn its orientation to that part all the time. You can read up on how to use AlignOrientation. There is more ways to do this you’ll see.

seems to keep the boat upright but now I cannot steer it? any suggestions?

You could do so the invisible part’s orientation in X and Z always will be equal to the boats. When you then try to AlignOrientation between boat and invisiblePart, then the boat will try to stay upright.

1 Like