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

Why do the Points stop increasing after first KO?

Asked by 8 years ago

Hello! The script below will successfully add points to my leaderboard after a player first kills another player. But, if they kill more, the points will not exceed the values below. Or if they exceed it once, like when the player is awarded points for surviving the round, the very next round when they kill another player, it reverts back to the values below. How can I make the values increase per kill? Thank you!

Players = game:GetService('Players')
Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(Character)
local Humanoid = Character:WaitForChild('Humanoid')
Humanoid.Died:connect(function()
if Humanoid:FindFirstChild('creator') ~= nil then
local Killer = Humanoid.creator.Value
Killer.leaderstats.Points.Value= Player.leaderstats.Points.Value+100 
Killer.leaderstats.EXP.Value= Player.leaderstats.EXP.Value+350  
end       
end)   
end)      
end)
0
any output? and why are you doing lines 8 and 9 like that? Killer.Leaderstats, then Player.Leaderstats RobloxianDestory 262 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Hello, Never2Humble!

Before, I used to have that same issue, and I solved it myself. I'll share with you my personal script, of earning Points/XP for each kill.

game.Players.PlayerAdded:connect(function(newPlayer)
local humanoid = script.Parent.Humanoid
script:clone().Parent = humanoid.Parent
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.Credits.Value = leaderstats.Credits.Value + 5
                leaderstats.EXP.Value = leaderstats.EXP.Value + 5
                wait(0.1) 
                script:remove() 
            end 
        end 
    end 
end 

humanoid.Died:connect(PwntX_X) 

If it does not work, Please feel free to ask!

0
It worked!!!! :D With just a bit of tweaking, it worked! Thank you good sir! Thank you! Never2Humble 90 — 8y
Ad

Answer this question