Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

create player Y position graph?

Asked by 5 years ago

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

01local function OnPlayerJoin(player)
02 
03     repeat wait() until player.Character
04 
05    local leaderstats = Instance.new("Folder")
06    leaderstats.Name = "leaderstats"
07    leaderstats.Parent = player
08 
09    local Height = Instance.new("IntValue")
10    Height.Name = "Height"
11    Height.Parent = leaderstats
12    while wait() do Height.Value = (player.Character.HumanoidRootPart.Position.Y - 8) end
13 
14 
15end
16 
17game.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

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. sahadeed 87 — 5y
0
what kind of event I should use to replace that while loops? jacobian65 19 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

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

1local maxheight = 200

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

1local Players = game.Players
2local LocalPlayer = Players. LocalPlayer
3local 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.

1gui.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.

0
Sorry, I meant UDim2 sahadeed 87 — 5y
1
Good answer royaltoe 5144 — 5y
0
Good comment @royaltoe sahadeed 87 — 5y
0
would be better if there is full code somewhere that I could just use for example though. jacobian65 19 — 5y
Ad

Answer this question