Why is my tag value nil?

I am trying to make a script that if you kill the humanoid it is in, you’ll get exp from it. I dont know if i am using the “humanoid:FindFirstChild(“creator”)” right because the value that it finds is nil even if my player is the one to kill that dummy. My game has abillities so maybe thats causing it.

script
local humanoid = script.Parent:WaitForChild(“Humanoid”)

humanoid.Died:Connect(function()

local tag = humanoid:FindFirstChild("creator")
print(tag)
if tag ~= nil then
	print("Works2")
	local player = tag.Value

	local Exp = 50
	

	local Stats = player:WaitForChild("Stats")
	Stats.Exp.Value = Stats.Exp.Value + Exp
end

end)

Gyazo
https://gyazo.com/c5d7bb5c1c696689a3066a1cb09e88c9

Script Location

https://gyazo.com/e523e1a0d20f103f58863c346aaa4005

1 Like

FindFirstChild returns whether the child exists or not. In this case creator dosn’t exist yet.
Also for the better don’t do if tag ~= nil then and instead do if not tag then.
If you want to wait for “creator” you could use WaitForChild But this does yeild which you need to not make infinite.
Be sure whatever is creating creator will exist.

1 Like

do u have any tips to make sure that whatever is creating creator will exist.

1 Like

Basically, just make sure that the player who killed the other exists.

2 Likes