Not just the Gui, either. Basically the whole game.
I am trying to make a health GUI i.e. "79/100".
I have tried following MANY tutorials online and got it to "work," but only when the game is run locally. As soon as I run a test server it completely stops working.
My code is such:
local player = game:GetService('Players').LocalPlayer.Character.Humanoid
game:GetService('Players').LocalPlayer.Changed:connect(function()
local redzone = player.MaxHealth / 4
if player.Health <= redzone then
script.Parent.BackgroundColor3 = Color3.new(255,0,0)
end
if player.Health > redzone then
local brickcolor = BrickColor.new("Lime green")
local color = brickcolor.Color
script.Parent.BackgroundColor3 = color
end
script.Parent.Size = UDim2.new(player.Health/player.MaxHealth,0,0,20)
script.Parent.Parent.hText.Text = (player.Health .. ' / ' .. player.MaxHealth)
end)
I know that this is a VERY basic question and I have spent three days working to solve it, but the resources online are not exactly robust.
edit: sorry for the weird Title, the site wouldn't let me post with my original

1 comment
When a player's health is changed, the game doesn't fire the Changed event in the player, but rather the humanoid. Try: player.Changed instead, since as seen on line 1, "player" refers to the humanoid.