Kills Are Not Registering The First Time

Greetings,

Edit: The script below has been fixed, check the comments below

I’m currently having trouble with my script which damages the player and inserts a creator tag to their humanoid. I think the tag is being created, but it can’t identify the user. I don’t see any outputs being created. Please tell me other possible ways to fix this issue, everything else in this script functions.

This is my current script:

script.Parent.Parent.MeleeDamage.OnServerEvent:Connect(function(player, x)
	local function TargetPlayer(hit)
		humanoid = hit.Parent:FindFirstChild("Humanoid")
		local tag = Instance.new("ObjectValue")
		tag.Value = humanoid.Parent.Name  -- This is where I think the trouble is happening, but can't identify possible solutions
		tag.Name = "creator"
		tag.Parent = humanoid
		game:GetService("Debris"):AddItem(tag,5)
	end
	if humanoid then
		humanoid:TakeDamage(35)
	end
	script.Parent.Parent.Parent.Hitbox.Touched:Connect(TargetPlayer)
	humanoid = nil
end)

Thanks for your time! Stay safe and well :mask:.

The issue is solved, but another one pursues, it won’t register the kill the first time, but will the proceeding times.

This is my new script where this problem pursues:

script.Parent.Parent.MeleeDamage.OnServerEvent:Connect(function(player, x)
	local function TargetPlayer(hit)
		humanoid = hit.Parent:FindFirstChild("Humanoid")
		local tag = Instance.new("ObjectValue")
		tag.Value = player
		tag.Name = "creator"
		tag.Parent = humanoid
		game:GetService("Debris"):AddItem(tag,5)
	end
	if humanoid then
		humanoid:TakeDamage(35)
	end
	script.Parent.Parent.Parent.Hitbox.Touched:Connect(TargetPlayer)
	humanoid = nil
end)

If you already had the solution, please reply to your own topic and mark it the solution.

Oops, you marked my reply, mark your own one!

Also don’t tag the title again. :slight_smile:

1 Like

I Am So Sorry, I Thought I’d Marked It Down