task.wait(0.1)
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local RunService = game:GetService("RunService") -- Gets one of my favourite services, RunService. This lets us fire functions every frame!
local ui = script.Parent
local text = ui:WaitForChild("TextLabel")
local RootPart = character:WaitForChild("HumanoidRootPart")
RunService.Stepped:Connect(function()
local RootPartStuds = RootPart.Position.Y
text.Text = RootPartStuds.." Studs"
end)
You’d have to round it. If you don’t care about it rounding to the nearest integer you could just use math.floor. But if you want it to be rounded use math.floor(RootPartStuds+.5).
The only article is the wiki page for math operations/functions. math.floor is a function that turns a double/float to an integer but it doesn’t round, so people do math.floor(double+.5) to round it up manually.
Your thinking of ceiling, floor rounds down. For example, if you called floor on 15.7, you’d get 15 and on 15.3, you’d also get 15. If you called ceiling on both of them you’d get 16.
No, math.floor does not do that unfortunately. Floor (bottom) always rounds down, regardless of the decimal… even if it is .999. math.ceiling rounds up, hence “ceiling” is up.
math.round automatically does what you are thinking of.
In order to accurately remove the decimal from the stud number, you can use math.round(). Alternatively, if you simply want to remove the decimal WITHOUT rounding, you can use math.floor()
The process is simple. All you would have to do is the following:
local RootPartStuds = math.round(RootPart.Position.Y) -- or math.floor
I’d recommend multiplying by 10 beforehand and then dividing by 10 afterwards that way using the screenshot provided the studs label would display “16.1”, rounding to the nearest integer might be too harsh/significant of a change (you could be off by a magnitude of 0.5 either way).