Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Im working on making a car with the new constraints and cannot get any movement ?

Asked by 3 years ago

My script is supposed to have two functions (driving and turning). It is supposed to monitor for the values changing in the vehicle seat. I fear that's where my problems stem from. I have set all the turn hinges up as servos and the drive hinges as motors, (pls ignore my inconsistencies) all the names are all 100% what they should be.

--Tuning--



--- -1 left/backwards



hp = 100
--max_gear = 4
turn_speed = 2
turn_angle = 45
--1 slow 5 fast

--------------------------------------------------------------
local rf  = script.Parent.Parent.rfl.steeringllower
local lf  = script.Parent.Parent.lfl.steeringllower
local rr  = script.Parent.Parent.RR.HingeConstraint
local lr  = script.Parent.Parent.RL.HingeConstraint
local rfu = script.Parent.Parent.RFU.steerlupper
local lfu = script.Parent.Parent.lfu.steerlupper
local turn  = script.Parent.Steer
local drive = script.Parent.Throttle

local function turn(value)
rf.TargetAngle = turn_angle * turn
rf.AngularSpeed = turn_speed * 10
lf.TargetAngle = turn_angle * turn
lf.AngularSpeed = turn_angle * 10
rfu.TargetAngle = turn_angle * turn
rfu.AngularSpeed = turn_speed * 10
lfu.TargetAngle = turn_angle * turn
lfu.AngularSpeed = turn_angle * 10

end
local function drive(value)
rr.MotorMaxTorque = hp * 100
lr.MotorMaxTorque = hp * 100
rr.AngularVelocity = drive * hp * 100
lr.AngularVelocity = drive * hp * -100



end
script.Parent.Steer.Changed:Connect(turn)
script.Parent.Throttle.Changed:Connect(drive)

i am also receiving this error everytime that i run it

Workspace.Model.VehicleSeat.Script:45: attempt to index number with 'Changed'

1 answer

Log in to vote
0
Answered by
jundell 106
3 years ago

You're trying to get the Changed signal of properties. Use GetPropertyChangedSignal instead.

script.Parent:GetPropertyChangedSignal("Steer"):Connect(turn)
script.Parent:GetPropertyChangedSignal("Throttle"):Connect(drive)

Also, the value argument of each function will be nil, so you can just remove that from each function since you aren't using it.

Ad

Answer this question