Humanoid.Died did not work

sure I will try it, also I just published it, you can test it with me if you want to, I can put the link
Edit: here’s the linkL (21) testing XP system - Roblox

1 Like

aww it doesn’t work even I publish the game

I cant join a private experience, please unlock it.

Edit: Nope, still locked.

1 Like

I think you can now, tell me if you still can’t

1 Like

bruh I changed the game to public but it didn’t save

k I make it public finally, check it out

let me bath now then I’m come back, brb

Well, just to clear something up for everyone here:

After speaking with @jj_forisland in game, it seems they didn’t want XP added for when a player eliminates another player but when a player eliminates a non-player humanoid object. Which can be accomplished with the following steps:

Create a folder in workspace called “EnemyObjects” then
Insert the code below into a ServerScript and place it in ServerScriptService.

local function getEnemy(humanoid) --Finding the enemy
	local Swordtag = humanoid:FindFirstChild("creator") ---Getting the tag the default sword adds
	if Swordtag ~= nil then
		local enemy = Swordtag.Value
		if enemy.Parent ~= nil then
			return enemy --Getting enemy to add XP in died event
		end
	end
	return nil
end

local function playerDied(humanoid)
	local killer = getEnemy(humanoid)
	if killer ~= nil then
		local leaderstats = killer:FindFirstChild("leaderstats")
		if leaderstats ~= nil then
			local enemyxp = leaderstats:FindFirstChild("XP")
			enemyxp.Value = enemyxp.Value + 1 --Giving enemy XP
		end
	end
end

for i,v in pairs(workspace.EnemyObjects:GetChildren()) do
	local humanoid = v:WaitForChild("Humanoid")
	humanoid.Died:connect(function() --When player dies
		playerDied(humanoid)
	end)
end

From here, you can edit the code to do whatever you want to the rigged/non-player humanoids after they’ve died. Just add in however many rigs with the rig builder, or however you want them to work, and you should be all set.

1 Like

Thx for making the script, I appreciated that a lot. It was good to see people help each other out.

Yep that’s what the forum is for. If it worked all good, please mark the message with the code as the solution.

sure I will do that, you are the first person to help me make a working script :smiley:

1 Like