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

How do I get my monster to give xp and gold to multiple people?

Asked by 8 years ago

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 '='

0
Why Not Just add The LeaderStats.XP.Value to the first function? Vezious 310 — 8y
0
It's not working. Either I am adding it wrong or it doesn't work for some other reason... Peanutthedestoyer 0 — 8y
0
though I will keep trying different combos for it. Hopefully one will work. :) Peanutthedestoyer 0 — 8y

2 answers

Log in to vote
0
Answered by
qwrn12 85
8 years ago

try giving the gold/xp to a area of studs i dont know how to code this though

0
Ok, thanks I'll look into it. Though with my 1 weeks worth of knowledge I am not sure how far I will get XD Peanutthedestoyer 0 — 8y
0
ok im glad i could help qwrn12 85 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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.

0
Thanks, I will also look into this solution to, and see where it takes me. :3 Peanutthedestoyer 0 — 8y
0
As I said I'm still rather new to scripting, but I was thinking about your idea and thought about using BoolValue to store the amount of times people hit it by using ClickDetector, and send it to the individual teams that I would set up to be individual players upon entering the game. Would this work? Peanutthedestoyer 0 — 8y
0
wait... forget all of that! What if I setup each sword to give XP to the player depending on the damage that they deal to a monster, and it will all be stored to the side until the monster died. :) Peanutthedestoyer 0 — 8y

Answer this question