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

how do I add score to my leaderboard stats when i kill an npc?

i have tried things like "if script.Parent.Health == 0 then 2 gold.value = gold.value +1" and "if Humanoid.Health == 0 then game.Player.leaderstats.gold.Value = game.Player.leaderstats.gold.Value.new(game.Player.leaderstats.gold.Value+10)"

neither of these worked, as my score stayed at 0. the currency here is Gold

2 comments

0

use humanoid.died for the npc to check when It dies

0

and then when the humanoid.died event fires get the last player that hit the mob and then give that player the points

1 answer

Make it so when you hit the NPC, you create an objectvalue named the player who attacked, then use the humanoid.Died function to check when the NPC is dead, and if dead, find the name of the objectvalue.Value in players and add to their stats.

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