Number value not changing help

I am trying to make a custom car chaisis system and this isn’t working

The number value on the top of the script isnt increasing

local speed = 0
local maxspeed = 35
local isdriving = true
local intvalueforspeed = 0

local uis = game:GetService("UserInputService")

local function speedchange(speed)
    if isdriving == true then
        spawn(function()
            speed = speed + 1
            print("addd")
        end)
        print(math.round(speed)) -- always 0
    end
end
local rs = game:GetService("RunService")

rs:BindToRenderStep("Throttle",Enum.RenderPriority.Camera.Value - 100,speedchange)

Could you elaborate more about the issue? Like, does the “addd” print?

1 Like

@rabbi99 the issue is solved

I will tell what was the issue
image

This parameter will return the elapsed time, like it will be 0.0001

So in this speed = speed + 1
it is adding 0.0001 = 0.0001 + 1, and the variable remains the same, I made this speed parameter into elaptime and now the variable changes

1 Like

Yup I see, I was just about to make a reply exactly like that! Good job on figuring it out yourself!

1 Like