Help with basic car

I have this script from a tutorial, its an older tutorial so i was trying to replace the deprecated stuff but the script still won’t work.

I get this error: MaxTorque cannot be assigned to - Server

-Heres The Script

local seat = script.Parent.VehicleSeat
local backL = script.Parent.BackL
local backR = script.Parent.BackR
local frontL = script.Parent.FrontL
local frontR = script.Parent.FrontR
local AngularVelocity = script.Parent.Base.AngularVelocity

seat.Changed:Connect(function ()
	if seat.Throttle == 1 then
		backL.HingeConstraint.AngularVelocity = 25
		backL.HingeConstraint.MotorMaxTorque = 10000
	elseif seat.Throttle == -1 then
		backL.HingeConstraint.AngularVelocity = -25
		backL.HingeConstraint.MotorMaxTorque = 10000
	elseif seat.Throttle == 0 then
		backL.HingeConstraint.AngularVelocity = 0
		backL.HingeConstraint.MotorMaxTorque = 0
	end
	if seat.Steer == 1 then
		AngularVelocity.MaxTorque = 10000
		AngularVelocity = Vector3.new(0,-5,0)
	elseif seat.Steer == -1 then
		AngularVelocity.MaxTorque = 10000
		AngularVelocity = Vector3.new(0,5,0)
	elseif seat.Steer == 0 then
		AngularVelocity.MaxTorque = 0
		AngularVelocity = Vector3.new(0,0,0)
	end
end)

The error “MaxTorque cannot be assigned to - Server,” suggests that there’s an issue with how you’re trying to set the MaxTorque property. This property belongs to AngularVelocity or BodyAngularVelocity constraints, so we need to ensure that the local variable angularVelocity can reference either of these constraints.

local seat = script.Parent.VehicleSeat
local backL = script.Parent.BackL
local backR = script.Parent.BackR
local frontL = script.Parent.FrontL
local frontR = script.Parent.FrontR
local angularVelocity = script.Parent.Base:FindFirstChild("BodyAngularVelocity") or script.Parent.Base:FindFirstChild("AngularVelocity")

seat.Changed:Connect(function ()
    if seat.Throttle == 1 then
        backL.HingeConstraint.AngularVelocity = 25
        backL.HingeConstraint.MotorMaxTorque = 10000
    elseif seat.Throttle == -1 then
        backL.HingeConstraint.AngularVelocity = -25
        backL.HingeConstraint.MotorMaxTorque = 10000
    elseif seat.Throttle == 0 then
        backL.HingeConstraint.AngularVelocity = 0
        backL.HingeConstraint.MotorMaxTorque = 0
    end

    if seat.Steer == 1 then
        if angularVelocity then
            angularVelocity.MaxTorque = Vector3.new(0, 10000, 0)
            angularVelocity.AngularVelocity = Vector3.new(0, -5, 0)
        end
    elseif seat.Steer == -1 then
        if angularVelocity then
            angularVelocity.MaxTorque = Vector3.new(0, 10000, 0)
            angularVelocity.AngularVelocity = Vector3.new(0, 5, 0)
        end
    elseif seat.Steer == 0 then
        if angularVelocity then
            angularVelocity.MaxTorque = Vector3.new(0, 0, 0)
            angularVelocity.AngularVelocity = Vector3.new(0, 0, 0)
        end
    end
end)
2 Likes

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