How to make a meter counter

Hello! So I am currently trying to make a game like Steep Steps and I want to know how to make a meter counter. I am not the best scripter, so what I did didn’t work. So how would I go about doing this? Thank you for your time and feedback. Have a great day!

1 Like

You just keep track of the player’s Y position. Roblox uses studs as the unit of length, and the correct conversion from studs to meters is controversial, so it’s up to you.

This is just an example; it prints out the altitude (distance from sea level which is when Y is 0) of the player every half second:

local lp = game:GetService('Players').LocalPlayer

--get the player's character model
local char = lp.Character or lp.CharacterAdded:Wait()
local hrp: BasePart = char:WaitForChild('HumanoidRootPart')

--whenever the player respawns, we need to reset the variables as well to their new model
	char = newChar
	hrp = newChar:WaitForChild('HumanoidRootPart')

local debounce: number = 0
	debounce += dt
	if debounce >= .5 then --every 0.5 seconds
		debounce = 0
		print(`Altitude: {math.floor(hrp.Position.Y + .5)}`) --rounded to the nearest whole number
1 Like

What I’m wanting is where as the player gets higher climbing the hill, the text of a label goes up by 5. Does that make sense? What would that look like? Keep in mind I’m not the best scripter lol. :slight_smile:

1 Like

For that, you can round the number to the nearest 5 with this syntax:

math.floor(number / ROUND_TO) * ROUND_TO

And getting it to display as a text should be trivial, you just set a TextLabel’s .Text property to the altitude.

I made a demo for you, you can play around with it:


Altimeter.rbxl (51.9 KB)

1 Like

For some reason, my label does this:
I don’t think my code is wrong:

local TextLabel = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart: BasePart = Character:WaitForChild("HumanoidRootPart")

	Character = newCharacter
	HumanoidRootPart = newCharacter:WaitForChild("HumanoidRootPart")

	TextLabel.Text = `<b>Meters:</b> {math.floor(HumanoidRootPart.Position.Y * .2) *5}`

Do you have RichText enabled on the label?

1 Like

That fixed it! Thank you so much!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.