Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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

0
use humanoid.died for the npc to check when It dies Synth_o 136 — 4y
0
and then when the humanoid.died event fires get the last player that hit the mob and then give that player the points Synth_o 136 — 4y

1 answer

Log in to vote
0
Answered by
Robowon1 323 Moderation Voter
4 years ago

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.

Ad

Answer this question