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

Clone a GUI to PlayerGUI when they kill a NPC not working, why?

Asked by 6 years ago

When the NPC dies it tags the player that is responsible for the NPCs death but it isn't working. Can someone please help me! I've tried for hours but I'm still not able to find a solution to this.

Script:

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
You need to use RemoteEvents for this to work. Make it so that after the npc is killed to fire a client event which then inserts the local script into the clients PlayerGui Impacthills 223 — 6y

Answer this question