Okay, so I know I'm not the best scripter but I tried my hardest and I can't seem to get this to work. I'm not even sure how off I am from getting it. The script is supposed to show a GUI to the player responsible for the death of a NPC when said NPC dies. However, I can't get it to work; can someone please help me? (I'm sorry if my script is horribly wrong)
Script:
local Humanoid = script.Parent.Humanoid -- NPC Humaniod Name function PwntX_X() local tag = Humanoid:findFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local MoveTo = tag:findFirstChild("PlayerGui") if MoveTo ~= nil then local gui = script.KillNoteGui:Clone() gui.Parent = MoveTo wait(0.1) script:remove() end end end end Humanoid.Died:connect(PwntX_X)
Try this version: (not tested)
local playerHumanoid = script.Parent.Humanoid; local function npcKilled() local tag = playerHumanoid:FindFirstChild("creator"); if(tag) and (tag.Value) ~= nil then local moveTo = game.Players[tag.Value]:FindFirstChild("PlayerGui") if(moveTo) then local cloneGui = script.KillnoteGui:Clone(); cloneGui.Parent = moveTo; wait(0.1) script:Destroy(); end end end playerHumanoid.Died:connect(npcKilled);