Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

2 comments

0

Please provide any errors from the output, etc...

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.

1 answer

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

1 comment

0

It's not working! :(

This discussion is preserved as it was. New answers, comments, and votes are closed.