So I've been learning from Roblox Wiki, and on one of the lessons is called "Making a Unit Frame" which shows you how to code it, but when I created it and joined my game, it doesn't show my username or my avatar, so I checked out the Developer Console and it says "Avatar not a valid member of frame" Here is the code I got from the Wiki:
local player = game.Players.LocalPlayer local unitFrame = script.Parent unitFrame.Avatar.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username=" .. player.Name unitFrame.PlayerName.Text = player.Name local healthBar = unitFrame.HealthBarContainer.HealthBar player.CharacterAdded:connect(function(character) local humanoid = character:WaitForChild('Humanoid') humanoid.HealthChanged:connect(function(health) local healthPercentage = health / character.Humanoid.MaxHealth healthBar.Size = UDim2.new(healthPercentage, 0, 1, 0) end) end) game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
And here's the picture from the Explorer: http://prntscr.com/8ok1u9
Is Avatar Inside The Frame?
Try this:
local player = game.Players.LocalPlayer local unitFrame = script.Parent.Parent:WaitForChild("UnitFrame") unitFrame.Avatar.Image = "http://www.roblox.com/Thumbs/Avatar.ashx?x=100&y=100&username=" .. player.Name unitFrame.PlayerName.Text = player.Name local healthBar = unitFrame.HealthBarContainer.HealthBar player.CharacterAdded:connect(function(character) local humanoid = character:WaitForChild('Humanoid') humanoid.HealthChanged:connect(function(health) local healthPercentage = health / character.Humanoid.MaxHealth healthBar.Size = UDim2.new(healthPercentage, 0, 1, 0) end) end) game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
WaitForChild is different from just dots because sometimes thing need to load and they haven't loaded, so it is a good thing you do this.
Please accept if helped.