Hello Scripters,
I have a BoatData module that stores all the data for my boats (I am currently using only one boat). When I change that boat’s speed to 2500, my boat accelerates like crazy. However, if I want it to only be 25, my boat doesn’t move at all. I’ve added print statements, and all the values are correct.
I’m assuming the calculations are causing issues because the ThrottleFloat
can sometimes be -1. I would greatly appreciate any help.
Here is the code:
local function configureBoat(possibleBoat)
if possibleBoat:IsA("Model") then
local Engine = possibleBoat:FindFirstChild("Engine")
local SForce = possibleBoat:FindFirstChild("Steer")
local DSeat = possibleBoat:FindFirstChild("VehicleSeat")
local Base = possibleBoat:FindFirstChild("Base")
local boatName = possibleBoat.RealName.Value
local boatInfo = BoatData[boatName]
if not boatInfo then
warn("Vehicle data not found for car:", boatName)
return
end
if boatInfo then
local speed = boatInfo["Speed"]
local steerSpeed = boatInfo["Steer"]
local baseDensity = boatInfo["Density"]
if Engine and SForce and DSeat and Base then
Base.CustomPhysicalProperties = PhysicalProperties.new(baseDensity, 0, 0)
local bodyThrust = Engine:FindFirstChild("BodyThrust") or Instance.new("BodyThrust", Engine)
bodyThrust.Force = Vector3.new(0, 0, 0)
DSeat:GetPropertyChangedSignal("ThrottleFloat"):Connect(function()
bodyThrust.Force = Vector3.new(0, 0, speed * DSeat.ThrottleFloat)
end)
DSeat:GetPropertyChangedSignal("SteerFloat"):Connect(function()
SForce.BodyAngularVelocity.AngularVelocity = Vector3.new(0, -steerSpeed * DSeat.SteerFloat, 0)
end)
end
end
end
end