How can you make a NPC When killed adds exp/kills in the linked leaderboard.
COMMUNITY QUESTION
How do you make an enemy npc when killed gives xp?
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.
