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

How do you make an enemy npc when killed gives xp?

How can you make a NPC When killed adds exp/kills in the linked leaderboard.

1 answer

Use a NumberValue, either stored in your player or on a leaderboard.

When an NPC dies, it finds WHO killed it, and adds XP.

--//NPC, Normal Script

NPC = script.Parent
LastAttacker = NPC.LastAttacker -- A String Value, that updates and when someone attacks


NPC.Humanoid.Died:connect(function()
	if game.Players:FindFirstChild(LastAttack.Value) then
		plr = game.Players[LastAttacker.Value]

		plr.leaderstats.XP.Value = plr.leaderstats.XP.Value + 5
	end
end)

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