Why isnt my script working?

Hi devs, i want to know why is my script not working. Im trying to make a car, but it wont move
script:

local seat = script.Parent.VehicleSeat

local backleft = script.Parent.BackLeft
local backright = script.Parent.BackRight

local frontleft = script.Parent.FrontLeft
local frontright = script.Parent.FrontRight

local steerAngle = 30
local speed = 60

seat:GetPropertyChangedSignal("Steer"):Connect(function()
	frontleft.PartB.SteeringConstraint.TargetAngle = steerAngle * seat.Steer
	frontright.PartB.SteeringConstraint.TargetAngle = steerAngle * seat.Steer
end)

seat:GetPropertyChangedSignal("Throttle"):Connect(function()
	frontleft.Wheel.WheelConstraint.AngularVelocity = speed * seat.Throttle
	frontright.Wheel.WheelConstraint.AngularVelocity = speed * seat.Throttle

	backleft.Wheel.WheelConstraint.AngularVelocity = speed * seat.Throttle
	backright.Wheel.WheelConstraint.AngularVelocity = speed * seat.Throttle
end)

im so confused why it isnt working when it should :confused:
thanks in advance

2 Likes

1–Set a movement vector2 variable

movement = Vector2.new()


car.DriveSeat.Changed:connect(function(property)
	if property == "Steer" then
		movement = Vector2.new(car.DriveSeat.Steer, movement.Y)
	elseif property == "Throttle" then
		movement = Vector2.new(movement.X, car.DriveSeat.Throttle)
	end
end)

you also need a run service that. makes it move use Wait() for connect not function
else if you want make it stable on every fps use that method by using 60 / dt

Also you doing the whole thing wrong use seat.Lookvector for the math since it will go the wrong side

and for it to stop use

for i, v in pairs(car:GetChildren()) do
	if v:IsA("BasePart") then
		mass = mass + (v:GetMass() * 196.2)
	end
end

and use if

	if movement.Y ~= 0 then

-- do your code here Make sure you calculate the look vector for steer not throttle

found out the bug, it wasnt with the script, it was with my hingeconstraits. i forgot to re add the properties.

do i delete post or like just leave it?

just make the message you made (finding out the bug) ur solution ig?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.