Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Overhead health GUI not going into all npcs?

I'm trying to make it so my overhead health GUI goes into every npc's Head so it's displayed above them without me having to manually add it to every single one. Was attempting to do so using a script that's meant to rename every part in the workspace to part1, part2, and so on but modifying it so it puts the overhead GUI into the head.
would rather do it with scripts than spend the next half hour adding it to their heads individually but it isn't working.

local parts = game.ServerStorage.NPCs:GetChildren() --Npcs is a folder
local BillboardGui = game.ReplicatedStorage.BillboardGui -- overhead gui is in replicated

for i, v in pairs(parts) do 
	
	if v:IsA("Model") then 
		BillboardGui:Clone(BillboardGui:GetChildren())
--trying to clone the billboardgui and the children (the Billboardgui itself, script, frame, and label)
		BillboardGui.Parent = parts.Head --put the gui in their head
		end
	end

The more detailed the response the better, thank you <3

1 answer

✓ Accepted answer

You could try this instead:

local parts = game.ServerStorage.NPCs:GetChildren() 
local BillboardGui = game.ReplicatedStorage.BillboardGui

for i, v in pairs(parts) do 

    if v:IsA("Model") then 
      local clonedUi = BillboardGui:Clone()
        clonedUi.Parent = v.Head
        end
    end

The reason why It's not working is because you were trying to set the parent of the UI to "Parts" which doesn't really work.

This discussion is preserved as it was. New answers, comments, and votes are closed.