[Help!] How to make character speed uppers in textlabel?

Hi Everyone !!!

I want to make character speed meter for my game, but i don’t know how to make it, can someone help me out if you have know please comment down below :slight_smile: , thank you so much developers.

To measure the “speed” of a character, assuming you mean how fast they’re going at a given moment, I would use a while loop to keep track of how far away you are from your last position .1 seconds ago. Use magnitude to get the distance

local lastPos = nil
local speed = 0
local player = game.Players.LocalPlayer
while wait(.1) do
    if not player.Character then
        continue
    end
    local hrp = player.Character.HumanoidRootPart
    if lastPos == nil then
        lastPos = hrp.Position
    else
        -- studs per second
        speed = (lastPos - hrp.Position).Magnitude * 10
        lastPos = player.Character.HumanoidRootPart.Position
    end
end

Then just apply the “speed” variable to your speed bar. To make it appear dynamic instead of a jittery bar, use Tweening.

Add this to the end of the while loop:

speedBar:TweenSize(
    UDim2.new(.1, 0, .1 * speed, 0),
    Enum.EasingDirection.Out,
    Enum.EasingStyle.Quad,
    .3,
    true
)
1 Like

Alternatively, you could calculate a character’s speed using their HumanoidRootPart's velocity property like in this post:

local speed = character.HumanoidRootPart.Velocity.Magnitude 
1 Like

Wow !!!, thank you so much it’s works :slight_smile: .

1 Like