[SOLVED] Overhead bar Ui not showing correctly for all players, only local

I have an issue with my Overhead UI health bar, It works perfect in local.

2

This is how it looks in local, is correctly.

1

But this is how others players see others players UIs.

3

Where the overhead UI and script is located.

1

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
3 Likes

You’re updating it locally. It won’t replicate to all players. You need to do this server sided in order for it to work.

3 Likes

Hello, sorry for the late response, but how could I do it? copying the script and pasting it inside serverscript service using a server script?

3 Likes

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.

3 Likes

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.

2 Likes

In your server script where you add the tag just make a reference to the health bar and the humanoid and handle it there.

2 Likes

This is what you could do:

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)
2 Likes

I tried it and the OverHead Ui appers like this to everyone.

1

1 Like

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)
6 Likes

Thanks for correcting my mistake, I was kind of rusing as I am also working on my own game at the same time!

2 Likes

No worries. I can understand the sheer pressure when you have to do both things. Good luck developing your game though!

2 Likes

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.

1

2 Likes
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.

2 Likes

On server, that won’t happen. It’s usually considered a bad practice to use WFC on server as server scripts loads first.

Hmmm… odd. Maybe it’s the UIListLayout instance you’re using? Can you show us the properties of your frame? The code logic seems fine.

1 Like

Wait, why are you using a UIListLayout to organize the contents inside the Billboard?

1 Like

Sure here is

1 Like

Are there any errors? It seems there is as the size of the bar seems to be that of what you set which means the code is having an error.

Also try this:

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
        billboard.HealthBarBackground.HealthBar.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,0)
Humanoid.HealthChanged:Cpnnect(function()
            billboard.HealthBarBackground.HealthBar.Size = UDim2.new(Humanoid.Health/Humanoid.MaxHealth,0,1,0)
        end
    end)
end)
1 Like

I’m not getting any error in console, if I use my script, if I use this one it works local for the player but no for global.

3

I try the code you gave me to check but where should I put it and a server side script right?

Also the character of the player is inside of a folder in workspace, maybe that is the issue?

1 Like

Yeah, you probably shouldn’t put the characters inside a folder, instead keep it in the workspace.

1 Like

You should put the new updated code in the server script which puts the tag instance in the players head.

1 Like