Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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!

2 answers

✓ Accepted answer

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
	game.Workspace.Model:SetPrimaryPartCFrame(0, i, 0) * math.Angles(math.rad(10), 0, math.rad(50))
end

2 comments

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

0

The last thing: is primarypart important, it depends

Yeah I think you need to script It to move

3 comments

0

Can you tell me whats wrong though.

0

wydm?

0

Like whats wrong in the code. So I got my answer to my second question, now i want the answer to my first

This discussion is preserved as it was. New answers, comments, and votes are closed.