t's been awhile since i've touched this script, but it's not even working. There's no errors, so i believe i'm doing this wrong. Anyways, to explain it briefly: ( BTW, it's in PlayerGui ) Basically, it creates a ScreenGui, and the script creates a BillboardGui that floats on top of it's head. (By putting it in their ScreenGui and setting the Adornee.)

Anyways, here's the script

local HealthBarGui = Instance.new("ScreenGui",script.Parent)
HealthBarGui.Name = "HealthBar"

function distanceAppear(plr1,plr2)
	while true do
	local plrname = plr1.Name
	if (plr1.Character.Head.Position - plr2.Character.Torso.Position).magnitude > 30 then
		local plrGUI = plr1.PlayerGui.HealthBar[plrname]
		plrGUI.HP.Visible = false
	else
		local plrGUI = plr1.PlayerGui.HealthBar[plrname]
		plrGUI.HP.Visible = true
	end
	wait()
	end
	return plr1,plr2
end

function grabplayers(plr)
	
	for i, player in ipairs (game.Players:GetPlayers()) do
	local Playername = player.Name
	
	if player.Character and plr.PlayerGui.HealthBar:FindFirstChild(Playername)== nil then
		local Billboard = Instance.new("BillboardGui",HealthBarGui)
		Billboard.Name = player.Name		
		Billboard.Adornee = player.Character.Head
		Billboard.AlwaysOnTop = true
		Billboard.Size = UDim2.new(1,0,1,0)
		Billboard.Enabled = true
		local clonehpthing = player.PlayerGui.ScreenGui.HP:Clone()
		clonehpthing.Parent = Billboard
		clonehpthing.Position = UDim2.new(0,0,0,0)
		clonehpthing.Size = UDim2.new(0,130,0,10)
		clonehpthing.Health:Destroy()
		clonehpthing.BorderSizePixel = 1
		print ("It finally works")
		distanceAppear(player,plr)
		
	end
	
	end
end

function GetPlayersFromGui(GUI)
	for i = 1, #GUI do
		GUI[GUI[i]] = true
	end
end

function Checkingfunc(plr1)
	
	script.Parent:WaitForChild("HealthBar")
	local GUIers = GetPlayersFromGui(plr1.PlayerGui.HealthBar:GetChildren())
	if GUIers ~= nil then
	for i, player in ipairs (game.Players:GetPlayers()) do
			local match = GUIers[player.Name]
			if not match then
				grabplayers(plr1)
			end
	end
	end
end

local localplayer = script.Parent.Parent
while true do
	Checkingfunc(localplayer)
	wait()
end

2 comments

1

What is it doing currently? Whats broken about it?

0

No GUI on other players. Nothing. Nada, Zero.