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

How to change a NumberValue's value?

Asked by 4 years ago

I want to change a NumberValue's value whenever the car goes backwards and forwards.

The NumberValue

local MS = seat.Speed.Value

The function that has to change the NumberValue's value.


local function onChanged(property) if property == "Throttle" then LD.AngularVelocity = MS * seat.Throttle RD.AngularVelocity = -MS * seat.Throttle if seat.Throttle >= 0 then MS = 77 print("going forward") else MS = 30 print("going backward") end end if property == "Steer" then LS.TargetAngle = SA * seat.Steer RS.TargetAngle = SA * seat.Steer end end seat.Changed:Connect(onChanged)

1 answer

Log in to vote
1
Answered by 4 years ago

You do


seat.Speed.Value = 50 -- Can be any value

If you store the value into a variable, it only stores the number not the actual instance, you have to do NumberValue.Value = 30 not MS = 30

0
So do I have to remove the MS variable? Gam3r_Play3r 47 — 4y
0
It worked, but it didn't change the cars' speed Gam3r_Play3r 47 — 4y
0
nvm, I managed to fix it Gam3r_Play3r 47 — 4y
Ad

Answer this question