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.
local Humanoid = script.Parent.Humanoid -- Change Enemy to the name of your Monsters Humaniod function PwntX_X() local tag = Humanoid:findFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local Leaderstats = tag.Value:findFirstChild("leaderstats") if Leaderstats ~= nil then Leaderstats.Gold.Value = Leaderstats.Gold.Value + 10 --How Much Money Given wait(0.1) script:remove() end end end end Humanoid.Died:connect(PwntX_X) local Humanoid = script.Parent.Humanoid -- Change Enemy to the name of your Monsters Humaniod function PwntX_X() local tag = Humanoid:findFirstChild("creator") if tag ~= nil then if tag.Value ~= nil then local Leaderstats = tag.Value:findFirstChild("leaderstats") if Leaderstats ~= nil then Leaderstats.XP.Value = Leaderstats.XP.Value + 8 --How Much Exp Given wait(0.1) script:remove() end end end end 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.
--Peanutthedestoyer (Sean Dennis) ClickDetector:connect(XPcounter) local Humanoid = script.Parent.Humanoid local Player = Humanoid:findFirstChild("Player") local ClickDetector = hittotal + 1/13 if hittotal = 1 then hittotal - 1/13 else nil if Humanoid.Died then Player.Leaderstats.XP.Value = Leaderstats.XP.Value + hittotal * 3 else nil if Player Died then Player hittotal = 0 else nil end end end end end
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 '='
try giving the gold/xp to a area of studs i dont know how to code this though
I think the best way of doing this is make the weapons you add a IntValue into the monster with the name of the player and the Value the damage that is dealt. With this you can also reward players who deal more damage.