My current issue is that I’m trying to clone a BilllboardGui as a ‘name’ for this NPC and made a script to delete the Gui when the NPC dies. However, my script only deletes BillboardGui in the StarterGui and not for PlayerGui. Is there any way around this?
(I’m doing this so that I can reduce amount of unnecessary unused GUIs in my server upon NPC regen)
Sorry, it has been around a week since I started coding so such an issue is due to my naivety and inexperience…
local function Gui()
local storedgui = game.ServerStorage.Merchant:Clone()
storedgui.Parent = game.StarterGui.Billboards.NPC
storedgui.Adornee = script.Parent:FindFirstChild("Head")
return storedgui
end
print("Success!")
local gui = Gui() -- basically storedgui will be what this variable is
local humanoid = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso") -- this is assuming the npc model has a Torso
humanoid.Died:Connect(function()
gui:Destroy()
end)