Why isn't my GUI updating when I change positions? [SOLVED BY MYSELF]
Asked by
4 years ago Edited 4 years ago
I am having some trouble with my code because I'm fairly new at scripting. I'm trying to create some code that will update a GUI whenever the player's HumanoidRootPart changes positions(Y-Axis), and I'm not sure what code to use to update it. I'm thinking of using a while loop but I'm not sure where to add it. The code is in a LocalScript and there are no errors in the output.
Any recommendations/help is appreciated.
Here is the code:
1 | game.Workspace:WaitForChild( "Humanoid" , 0.05 ) |
3 | local character = game.Players.LocalPlayer.Character |
4 | local textLabel = script.Parent |
5 | local rootpartPositionY = character.HumanoidRootPart.Position.Y |
6 | local rootpartPositionYnum = math.floor(rootpartPositionY* 1 )/ 1 |
9 | textLabel.Text = (rootpartPositionYnum .. " s" ) |
EDIT: I have fixed this code by adding a "while true do" at the start of my code.
Like this:
02 | game.Workspace:WaitForChild( "Humanoid" , 0.05 ) |
04 | local character = game.Players.LocalPlayer.Character |
05 | local textLabel = script.Parent |
06 | local rootpartPositionY = character.HumanoidRootPart.Position.Y |
07 | local rootpartPositionYnum = math.floor(rootpartPositionY* 1 )/ 1 |
09 | textLabel.Text = (rootpartPositionYnum .. " s" ) |