#Hi can somoane help me with my Boat Banking/Steering script
1 messages · Page 1 of 1 (latest)
heres my script:
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local BoatKeybinds = ReplicatedStorage:WaitForChild("BoatKeybinds", 10)
local SeatEvent = ReplicatedStorage:WaitForChild("SeatEvent", 10)
local Model = workspace:WaitForChild("BoatModel")
local ppart = Model.PrimaryPart
local VectorForce = ppart:WaitForChild("VectorForce")
local Seat = Model:WaitForChild("Seat")
local SteeringVelocity = ppart:WaitForChild("SteeringVelocity")
local BankingVelocity = ppart:WaitForChild("BankingVelocity")
local MaxSpeed = 50
local AccelarationForce = 5000
local DesiredForce = vector.create(5000,0,0)
local LatestPlayer = nil
local SteeringAmountA = 0
local SteeringTargetA = 0
local SteeringAmountD = 0
local SteeringTargetD = 0
local BankingAmountA = 0
local BankingTargetA = 0
local BankingAmountD = 0
local BankingTargetD = 0
ppart:SetNetworkOwner(nil)
local function ForceChanger(Speed)
if Speed < MaxSpeed then
VectorForce.Force = DesiredForce
else
local factor = math.clamp(1 - ((Speed - MaxSpeed)/MaxSpeed), 0, 1)
VectorForce.Force = DesiredForce * factor
end
end
RunService.Heartbeat:Connect(function()
local Speed = ppart.Velocity.Magnitude
ForceChanger(Speed)
end)
RunService.Heartbeat:Connect(function(deltatime)
if SteeringAmountA > SteeringTargetA then
SteeringAmountA = SteeringAmountA - 0.005
elseif SteeringAmountA < SteeringTargetA then
SteeringAmountA = SteeringAmountA + 0.005
end
if SteeringAmountD > SteeringTargetD then
SteeringAmountD = SteeringAmountD - 0.005
elseif SteeringAmountD < SteeringTargetD then
SteeringAmountD = SteeringAmountD + 0.005
end
if BankingAmountA > BankingTargetA then
BankingAmountA = BankingAmountA - 0.02
elseif BankingAmountA < BankingTargetA then
BankingAmountA = BankingAmountA + 0.02
end
if BankingAmountD > BankingTargetD then
BankingAmountD = BankingAmountD - 0.02
elseif BankingAmountD < BankingTargetD then
BankingAmountD = BankingAmountD + 0.02
end
local FinalSteering = SteeringAmountA + SteeringAmountD
local FinalBanking = BankingAmountA + BankingAmountD
-- Auto-level when not banking
--if BankingTargetA == 0 and BankingTargetD == 0 then
-- local _, _, currentRoll = ppart.CFrame:ToOrientation()
-- FinalBanking = -currentRoll * 1.5
--end
SteeringVelocity.AngularVelocity = Vector3.new(0, FinalSteering, 0)
BankingVelocity.AngularVelocity = Vector3.new(0, -FinalBanking, 0)
end)