So I am trying to fix my friends boat script, I have tried printing it out with no luck, sometimes when spawned in through replicated storage it will float and work correctly sometimes not, I have a taken into account to disable the script in replicated storage and activate when spawned in, but I just cant figure out why its only working part of the time.
prop = script.Parent:WaitForChild("Propeller")
vehicleseat = script.Parent:WaitForChild("VehicleSeat")
vehicleseat.MaxSpeed = 50 -- change this for speed
engine = prop:WaitForChild("Engine")
steer = engine:WaitForChild("Steering")
particles = engine:WaitForChild("ParticleEmitter")
thrust = engine:WaitForChild("BodyThrust")
maxSteer = 40
minSteer = 20
steer.ServoMaxTorque = 1.5 * 10^4
steer.AngularSpeed = vehicleseat.TurnSpeed
multiplier = 1.3 * 10^1
mass = 0
for i, v in pairs(script.Parent:GetChildren()) do
if v:isA("BasePart") then
mass = mass + v:getMass()
end
end
function checkIfPointUnderWater(position)
local point = workspace.Terrain:WorldToCell(position)
local center = workspace.Terrain:CellCenterToWorld(point.X, point.Y, point.Z)
local region = Region3.new(center-Vector3.new(2,2,2), center+Vector3.new(2,2,2))
local material = workspace.Terrain:ReadVoxels(region, 4)
return material[1][1][1] == Enum.Material.Water
end
game:GetService("RunService").Heartbeat:connect(function()
if checkIfPointUnderWater(engine.Position) then
thrust.Force = Vector3.new(0,0,-vehicleseat.Throttle * vehicleseat.Torque)*mass*multiplier * math.min(1, 2 - vehicleseat.Velocity.magnitude / vehicleseat.MaxSpeed)
particles.Speed = NumberRange.new(vehicleseat.Velocity.magnitude)
particles.Enabled = true
if vehicleseat.Throttle < 0 then
thrust.Force = thrust.Force / 4
particles.Speed = NumberRange.new(-vehicleseat.Velocity.magnitude)
end
else
particles.Enabled = false
thrust.Force = Vector3.new()
end
steer.TargetAngle = -vehicleseat.Steer * (maxSteer - (vehicleseat.Velocity.magnitude / vehicleseat.MaxSpeed)*(maxSteer-minSteer))
end)
In the output, there are two errors- from two different scripts.
In the OP, which script did you provide? Workspace.DatBoat.Welder or Workspace.DatBoat.Humanoid.Script?
Please provide the one you haven’t provided as well
the humanoid script has nothing to do with it ill post the welder script
Utility = LoadLibrary("RbxUtility")
Create = Utility.Create
Welds = {}
function popFromTable(list, key)
for i, v in pairs(list) do
if v["key"] == key then
local data = v
table.remove(list, i)
return data
end
end
end
function quickWeld(node)
local data = popFromTable(Welds, node)
local root = node:findFirstChild("Root") or node:getChildren()[1]
if data == nil then
data = {key = node, cframe = {}, welds = {}}
for _,v in pairs(node:getChildren()) do
if v ~= root and v:isA("BasePart") then
table.insert(data["cframe"], {root, root.CFrame:toObjectSpace(v.CFrame), v})
v.Anchored = false
end
end
end
for _, v in pairs(data["welds"]) do
v:Destroy()
end
for _,v in pairs(data["cframe"]) do
if v ~= root then
table.insert(data["welds"], Create("Weld"){
Name = "QuickWeld",
Part0 = v[1],
Part1 = v[3],
C0 = v[2],
C1 = CFrame.new(),
Parent = v[3]
})
end
end
root.Anchored = false
table.insert(Welds, data)
end
quickWeld(script.Parent)
You should not use LoadLibrary as it is going to be removed, as states in the output. The script in the humanoid errors though, are you using the correct assetId ro get a module?
These errors happen even when it works correctly, I also did not make this script, simply trying to fix it for my friend, in the humanoid script its only used to load a explosion, the boat has a humanoid when it dies it explodes, however I redid that script just never took the humanoid script out.
the error is due to trying to load a asset for the explosion