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

Show the killer a GUI when the NPC dies script not working, why?

Asked by 6 years ago

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)
0
Please provide any errors from the output, etc... UnleashedGamers 257 — 6y
0
Nothing in the output is related to the script. That's another reason as to why I can't figure out how to do it. Michael_TheCreator 166 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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);
0
It's not working! :( Michael_TheCreator 166 — 6y
Ad

Answer this question