I’ve build a boat but it keeps falling over. Please see video:
Properties of the boat:
Here is my script:
local Seat = script.Parent.VehicleSeat
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {workspace.Terrain}
Params.FilterType = Enum.RaycastFilterType.Whitelist
Seat.Changed:Connect(function()
script.AngularVelocity.AngularVelocity = Vector3.new(0, -1 * Seat.Steer,0)
script.LinearVelocity.LineVelocity = 50 * Seat.Throttle
end)
while task.wait() do
local sPos = script.Parent.VehicleSeat.Position + Vector3.new(0,5,0)
local ePos = script.Parent.VehicleSeat.Position - Vector3.new(0,15,0)
local ray = workspace:Raycast(sPos,ePos - sPos,Params)
if ray and ray.Material == Enum.Material.Water then
script.AngularVelocity.Enabled = true
script.LinearVelocity.Enabled = true
else
script.AngularVelocity.Enabled = false
script.LinearVelocity.Enabled = false
end
end