I have an issue with my Overhead UI health bar, It works perfect in local.
This is how it looks in local, is correctly.
But this is how others players see others players UIs.
Where the overhead UI and script is located.
This is where the overhead is when the player is on the game
The “Characters” folder is inside the workspace and then the character, the “Tag” is inside the head.
My code of the script.
Character = game:GetService("Players").LocalPlayer.Character
wait(1)
while wait() do
script.Parent.Size = UDim2.new(Character.Humanoid.Health / Character.Humanoid.MaxHealth, 0, 1, 0)
end
Yes and no. You would have to modify the code a bit to work on the server. I don’t really know how your overhead gui really works but it’s usually by parenting the script to the billboard gui and using Instance.Parent to navigate to the player and then get the humanoids health.
I have a server script in serverscriptservice that makes the tag to apper inside the player, while the AnimationScript is inside the HealthBar, the tag works for everyone except the healthbar that is only local, that is what I’m trying to fix somehow, maybe adding a serverside script and changing the script will make it work I guess.
local ServerStorage = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local billboard = ServerStorage:WaitForChild("HealthBarBackground"):Clone()
billboard.Parent = char.Head
while wait() do
-- Do the Scaling Here!
end
end)
end)
Correction, you are referencing the wrong instance here, you should do:
local billboard = ServerStorage:WaitForChild("Tag"):Clone()
Also, don’t use while loops, they aren’t performant at all! Use Humanoid.HealthChanged instead.
So:
local ServerStorage = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local billboard = ServerStorage:WaitForChild("Tag"):Clone()
billboard.Parent = char.Head
local Humanoid = char.Humanoid
Humanoid.HealthChanged:Cpnnect(function()
billboard.HealthBarBackground.HealthBar.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,0)
end
end)
end)
Sadly It happens the same as above, I tried it in a local script, server script, moved it to inside the HealthBar, serverscriptservice and startercharacterscript, in all of them the same.
local ServerStorage = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local billboard = ServerStorage:WaitForChild("Tag"):Clone()
billboard.Parent = char:WaitForChild("Head")
local Humanoid = char:WaitForChild("Humanoid")
Humanoid.HealthChanged:Connect(function()
billboard.HealthBarBackground.HealthBar.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,0)
end
end)
end)
I would change it to this, just incase the character loads late.