How do I get my monster to give xp and gold to multiple people?
Hello,
I got this script to be able to drop xp correctly to 1 player. Though I don't know how to make it give it to multiple people who attack it. Whenever I try to do it myself it either gives it all to the last person who attacked it or gives all the players nothing. Do any of you know how to fix it?
This is the script for my XP/Gold drop. If you need anything else to help me out please do ask.
Thanks,
Peanutthedestoyer
--On lines 10 and 29 change Gold to the name of your money and Exp to the stat you wish to upgrade.
01 | local Humanoid = script.Parent.Humanoid |
03 | local tag = Humanoid:findFirstChild( "creator" ) |
05 | if tag.Value ~ = nil then |
06 | local Leaderstats = tag.Value:findFirstChild( "leaderstats" ) |
07 | if Leaderstats ~ = nil then |
08 | Leaderstats.Gold.Value = Leaderstats.Gold.Value + 10 |
15 | Humanoid.Died:connect(PwntX_X) |
20 | local Humanoid = script.Parent.Humanoid |
22 | local tag = Humanoid:findFirstChild( "creator" ) |
24 | if tag.Value ~ = nil then |
25 | local Leaderstats = tag.Value:findFirstChild( "leaderstats" ) |
26 | if Leaderstats ~ = nil then |
27 | Leaderstats.XP.Value = Leaderstats.XP.Value + 8 |
34 | Humanoid.Died:connect(PwntX_X) |
I got some clues on where to look and tried putting together a script of my own that might be on the right track, but I'm not sure yet.
04 | ClickDetector:connect(XPcounter) |
06 | local Humanoid = script.Parent.Humanoid |
07 | local Player = Humanoid:findFirstChild( "Player" ) |
08 | local ClickDetector = hittotal + 1 / 13 |
14 | Player.Leaderstats.XP.Value = Leaderstats.XP.Value + hittotal * 3 |
If anyone sees any big problems with this script please do reply. I just noticed I'm getting a error with this script and more with other scripts that I don't understand how to fix. The error is Error: (9,14) Expected 'then', got '='