so im make a ModuleScript that uses properties from a vehicleSeat and even tho the seat does exist and studio shows me the properties im trying to read, i get "attempted to call a nil value" with no reference to where it happened in the code. im reading the MaxSpeed, Torque, ThrottleFloat ,SteerFloat, and TurningSpeed properties
ive broken down the code and for some reason the error starts when i read from steering and throttle
ive made a test server script that read the steering and throttle and sum reason that 1 works yet i got this script working b4 in a module script
i also tried passing the properties as function parameters and it still happens
it does work if i pass a number tho
heres the code
local Controller = require(script.Parent.BasicSedanDoorController)
Controller.DriverSeat.Changed:Connect(Controller.Drive())
local Controller = {}
vehicle = script.Parent
Controller.DriverSeat = vehicle.body.DriverSeat.VehicleSeat
suspension = vehicle.Suspension
turningRadius = 45
Parts = {
Steering = {
FL = suspension.FrontLeftArm.Hub.CylindricalConstraint,
FR = suspension.FrontRightArm.Hub.CylindricalConstraint
},
driveTrain = {
RL = suspension.RearLeftArm.Hub.MotorConstraint,
RR = suspension.RearRightArm.Hub.MotorConstraint
},
Lights = {
}
}
topSpeed = Controller.DriverSeat.MaxSpeed
Parts.driveTrain.RL.MotorMaxTorque = Controller.DriverSeat.Torque
Parts.driveTrain.RR.MotorMaxTorque = Controller.DriverSeat.Torque
Parts.Steering.FL.AngularSpeed = Controller.DriverSeat.TurnSpeed
Parts.Steering.FR.AngularSpeed = Controller.DriverSeat.TurnSpeed
Parts.Steering.FL.ServoMaxTorque = 1000000
Parts.Steering.FR.ServoMaxTorque = 1000000
function Controller.DoorController(door:Model)
local servo: HingeConstraint = door:WaitForChild("Exterior"):WaitForChild("Servo")
if servo.TargetAngle == 180 then
servo.TargetAngle = 120
else
servo.TargetAngle = 180
end
end
function Controller.Drive()
Parts.Steering.FL.TargetAngle = Controller.DriverSeat.Steer
Parts.Steering.FR.TargetAngle = Controller.DriverSeat.Steer
Parts.driveTrain.RL.AngularVelocity = Controller.DriverSeat.Throttle
Parts.driveTrain.RR.AngularVelocity = Controller.DriverSeat.Throttle
end
return Controller