hello, I’m currently working on a car game but the car doesn’t work. I’m making it by scratch and I’m not so good at scripting so pls give some feedback. Thanks
Here’s some pictures and the code.
note: the code is inside the VehicleSeat.
local leftwheel = script.Parent.Parent.LeftWheel
local leftwheel2 = script.Parent.Parent.LeftWheel2
local rightwheel = script.Parent.Parent.RightWheel
local rightwheel2 = script.Parent.Parent.RightWheel2
local steer = script.Parent.Parent.Stear
local speed = 80
script.Parent.Changed:Connect(function(property)
leftwheel.AngularVelocity = speed * script.Parent.Throttle
leftwheel2.AngularVelocity = speed * script.Parent.Throttle
rightwheel.AngularVelocity = speed * -script.Parent.Throttle
rightwheel2.AngularVelocity = speed * -script.Parent.Throttle
steer.TargetAngle = 15 * -script.Parent.Steer
end)
First, check this line out: local steer = script.Parent.Parent.Stear
Stear should be Steer.
When you say “the doesn’t work” you need to tell us specifically what it is/isn’t doing and what you expect it to do.
Also, are there any errors in the Output Window when you test it in Studio?
Next, are the HingeConstraint Attachment0 and Attachment1 connected to the right Attachments?
Are there any welds between the Wheel and the chassis of the car? I’d suggest using WeldConstraints to select the Parts you want welded. If you use the welds from the Join Always tool in Studio it will weld the touching Parts together and may even be welding the wheels to the Baseplate.
Are any of the Parts Anchored?
Are the HingeConstraints.ActuatorType set to ‘Motor’?
What is the HingeConstraint.MotorMaxTorque set to? If it’s too low your hinges (motors) won’t be able to spin.