1

# Why isn't the code working when the part is welded?

Xyternal 218
1 year ago

So I was searching up some YouTube tutorial videos, and I wanted to make my boat move. Here is my code.

local Engine = game.Workspace.car.Model.Engine.BodyThrust --The Force making the boat move
local SForce = game.Workspace.car.Steer.BodyAngularVelocity -- The force making the boat turn
local DSeat = script.Parent -- The driver seat
local Base = game.Workspace.car.Model.Base -- The base part of the boat

speed = 5000 -- The force of 'Engine'
SteerSpeed = 25 -- The force of SForce
BaseDensity = .1 -- Lower this is your boat can't float, make it higher to make it go more in the water

DSeat.Changed:Connect(function(p)
if p == "ThrottleFloat"then
Engine.Force = Vector3.new(0,0,speed * DSeat.ThrottleFloat)
end
if p == "SteerFloat"then
SForce.AngularVelocity = Vector3.new(0,-SteerSpeed*DSeat.SteerFloat,0)
end
end)

Base.CustomPhysicalProperties = PhysicalProperties.new(BaseDensity,0,0)


So it works when I test it without welding the engine, but when i weld the engine, the boat doesn't move. One more question... I have a drivers seat, and do i need a script to make it move? Please answer my questions. Thanks!

1
Xapelize 2285
1 year ago
Edited 1 year ago

Hey! I believe that you are trying to move an entire boat, but it looks like your welded part is anchored! That's why it wont move, you should make it as a model, and go to the model > properties > PrimaryPart, set it to the base part of the boat.

Now you should move it with :SetPrimaryPartCFrame, rotating it need to use math.Angles, just a note, every orientation you put should do math.rad. Heres a sample:

for i = 1, 100, 1 do
end

0
Everything you put in the model will be moved when you put SetPrimaryPartCFrame, by the way, it's all entirely moved to a direction based on the PrimaryPart, so you should not use pairs loop because it squashes all the parts inside a setted direction which does not work Xapelize 2285 — 1y
0
The last thing: is primarypart important, it depends Xapelize 2285 — 1y