How can I make a GUI pop up when NPC/Enemy dies? (pls help)

my script: (this is a normal script inside of the npc)

local Frame = game.StarterGui.BossDeath.Frame

while true do
wait()
if script.Parent ~= nil then
if script.Parent.Humanoid.Health <= 1 then

Frame.Visible = true
wait(4)
Frame.Visible = false
end
end

end

sorry guys… this is my first post. Idk why my script example ended up looking like that

Well, first, you can only change GUI with Localscript, and second, the StarterGui is not where the player’s GUI is. It acts like the StarterPack. It’s just what gets put there when you spawn in, but you can’t interact with it as if it was the player’s.
use a
Remote event and FireServer on your MainServer and then Use OnServerEvent on local script

Make a gui, insert script in it that will make gui pop up on remote trigger. Remote will be in ReplicatedStorage.
In ServerScriptService make script like

Players.OnPlayerAdded:Connect(function(plr) 
      plr.CharacterAdded:Connect(function(char) 
            char.Humanoid.Died:Connect(function((
                  remoteFireClient(plr) --Remote that should be triggered on death
            end) 
      end) 
end) 

OHH, sorry, I thought you need on player death script!

BossHum.Died:Connect(function() 
   BossDeath:FireAllClients() 
end)