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