I have two teams in my game, one of them consists of only one player that is to have a custom health GUI to appear on EVERYONE's screen, but the health GUI is supposed to be ONLY for the health of the single player that is on a different team from everyone else. Kinda like a big zombie/villain.
I already have the GUI created, it is just a matter of scripting so that whenever that zombie/villain takes damage, everyone will see the healthbar get smaller on their screen. I believe I need to use a RemoteEvent to Invoke the Client or something, right? I am having trouble how to link the RemoteFunction with the client...the wiki is rather confusing. A skeleton or some pointers would be really helpful. What I have so far is a RemoteFunction in Workspace and this script
local player = game.Players:GetChildren()
local remote = game.Workspace.RemoteServer_BossHealth.RemoteEvent
local healthbar = player.PlayerGui.BossHealth.Healthbar
local humanoid = player.Character:FindFirstChild("Humanoid")
while true do wait()
if player.TeamColor == BrickColor.new("Bright red") then
local boss = player
boss.HealthChanged.Changed:connect(function() --Make all PlayerGUIs for the healthbar change if the Boss gets damaged
local originalSize = healthbar.Size.X.Offset
remote:FireAllClients(player.PlayerGui.BossHealth.HealthBar.Size == UDim2.new(0, humanoid.Health / humanoid.MaxHealth * originalSize, 0, 100))
end)
end
end

1 comment
Have you tested this? (The first step towards a solution is testing.)