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

How does one show a player a GUI when they kill a specific NPC?

Asked by 6 years ago

When a player kills a NPC it's supposed to show the killer a GUI but it isn't working. Someone please help! I've been stuck on this for a couple of weeks now and it's really hindering the progress of my game! :(

What I'm trying to achieve is that when a player kills a "Normal Zombie" a GUI comes onto their screen that says "100 Points". However, if they kill a "Tank Zombie" they will get a GUI that says "500 Points". I know how to script everything else I just need help on actually giving the killer a GUI.

Code:

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);

Answer this question