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

Why is my TextLabel not updating?

So Im trying to fix the GUI that displays my health, character name, chara image, gold, and walkspeed. The chara image and the character name works perfectly but the gold doesnt seem to work at all, I already used LocalScript and changed the PlayerGui instead of StarterGui but nothing happened, any help? Here is the script that is controlling the GUI

local PlayerGui = game.Players.LocalPlayer.PlayerGui.GuiPack.NewFrame

while true do
local Player = game.Players.LocalPlayer
PlayerGui.CharName.Text = Player.Name
PlayerGui.CharacterPortrait.Character.Image = "http://www.roblox.com/thumbs/avatar.ashx?x=352&y=352&format=png&username="..Player.Name
PlayerGui.CharacterPortrait.Level.Text = "Lvl " ..Player.leaderstats.Level.Value
PlayerGui.HealthBar.CurrentHP.Text = math.floor(Player.Character.Humanoid.Health).. " / " ..math.floor(Player.Character.Humanoid.MaxHealth)
PlayerGui.GoldBox.Text = Player.leaderstats.Gold.Value
PlayerGui.WalkSpeed.Text = Player.Character.Humanoid.WalkSpeed
wait(0.1)
end

4 comments

0

There any errors?

0

I cant find an error but it doesnt work, lemme try to check

0

What I see is the message "Character is not a valid member of model"

0

Instead of updating everything constantly, it's probably better if you keep track of when the player gets hurt or when their level changes etc. so you know when to update the UI.

1 answer

✓ Accepted answer

i think if u replace

PlayerGui.WalkSpeed.Text = Player.Character.Humanoid.WalkSpeed

with

PlayerGui.WalkSpeed.Text = Player:FindFirstChild("Character").Humanoid.WalkSpeed

that should maybe work since it will only work if the character exist and findfirstchild does that if it dont work then you should do this

if Player:FindFirstChild("Character") then
PlayerGui.WalkSpeed.Text = Player:FindFirstChild("Character").Humanoid.WalkSpeed
end

that will make the character part work only if there is a character, alternatively if the humanoid dont exist then do this

if Player:FindFirstChild("Character") then
PlayerGui.WalkSpeed.Text = Player:FindFirstChild("Character"):WaitForChild("Humanoid").WalkSpeed
end

this will wait for the humanoid to load once the character exists

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