A "you killed this player" gui not working

What I want to happen is when one player kills another player, a GUI to appear on the killer’s screen that says “you killed (victim).” I have the code written, and I found that the script knows who killed who by print debugging (based off the creator tag from classic roblox weapons). The problem is, the script for some reason doesn’t think that PlayerGui exists! When the script runs and the victim dies, it errors: "PlayerGui is not a valid member of Player “Players.(victim)” ". The way that I am making the GUI appear is by cloning a frame from ReplicatedStorage into a specific ScreenGui inside of the killer’s PlayerGui named “KillNotify”.

I would like to know why I’m getting that error, and a possible fix please!
Here’s my code, it’s a local script located inside of KillNotify:

local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')

hum.Died:Connect(function()
	local killer = hum:FindFirstChild("creator").Value
	--print(killer.ClassName)
	--print("found killer "..killer.Value)
		local gui = game.ReplicatedStorage.YouKilledGui:Clone()
		gui.Parent = killer.PlayerGui.KillNotify
		gui.TextLabel.Text = "You Killed: "..hum.Parent.Name
		gui.Visible = true
		gui.TextLabel.Visible = true
		wait(10)
		gui.Visible = false
		gui.TextLabel.Visible = false
		gui:ClearAllChildren()
		gui:Destroy()
	--end
end)

Is the creator tag a string value?

No, the creator tag is from Roblox’s default sword code, it creates an ObjectValue like this:

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

The problem is that you’re trying to access Player2’s PlayerGui from Player1’s client, which will return nil since it’s not possible.

1 Like