Hey, I’m trying to make a script that constantly updates the text in a GUI with the player’s velocity, but it doesn’t seem to work.
Just to be clear, there are no errors in the output. The number just stays stuck at 0
The code I'm trying to use for this
local player = game:GetService("Players").LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local text = script.Parent
local velocity = (character.HumanoidRootPart.Velocity * Vector3.new(1,0,1)).Magnitude
function roundNumber(num, numDecimalPlaces)
return string.format("%." .. (numDecimalPlaces or 0) .. "f", num)
end
game:GetService("RunService").RenderStepped:Connect(function()
text.Text = roundNumber(velocity, 1)
end)
Help is appreciated, thank you in advance.