Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

create player Y position graph?

hi there, I had been able in creating a player Y position indicator that can display how high is the humanoid from the ground. which is beneficial in determining the success factor in the game I am creating. kind of like tower of hell.

here is the code that I created that shows the player's height from the ground in the leaderstat. and here is the screenshot of the said leaderstat

local function OnPlayerJoin(player)
	
	 repeat wait() until player.Character
 
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Height = Instance.new("IntValue")
	Height.Name = "Height"
	Height.Parent = leaderstats
	while wait() do Height.Value = (player.Character.HumanoidRootPart.Position.Y - 8) end
	

end

game.Players.PlayerAdded:Connect(OnPlayerJoin)

but right now I am trying to turn this number info into a graph like tower of hell did. any suggestion of how I can turn it in like a graph in Tower of Hell game did?

here is the TOH screenshot. graph

2 comments

0

Avoid using while loops. Try to use an event to start the function instead, as while loops cause severe lag when there are many players in the game.

0

what kind of event I should use to replace that while loops?

1 answer

✓ Accepted answer

Quite easy. First, I would get the max height of the graph (the end of the tower):

local maxheight = 200

Then, I would get the percentage completion of tower (percent formula is numerator divided by denominator)

local Players = game.Players
local LocalPlayer = Players. LocalPlayer
local percentage = LocalPlayer.leaderstats:FindFirstChild(“Height”) / 200

Then, I would move the player’s head in the gui up depending on the percentage completed. Use a for loop to update each gui. Replace blablabla with the constant Xpos scale.

gui.Position = UDIM2.new(blablabla,0,1 - percentage, 0)

That is the logic for a Ypos graph. Sorry for any syntax or formatting errors; I am typing this on mobile at school.

4 comments

0

Sorry, I meant UDim2

1

Good answer

0

Good comment @royaltoe

0

would be better if there is full code somewhere that I could just use for example though.

This discussion is preserved as it was. New answers, comments, and votes are closed.