Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Overhead health GUI not going into all npcs?

Asked by
Synkthh -3
2 years ago

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

Log in to vote
0
Answered by
Hypoxla 125
2 years ago
Edited 2 years ago

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.

Ad

Answer this question