Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can a value be increased in a specific column (leaderboard)?

I just want to expand on this (based on touching a part and a value going up):

function onTouch(part) 
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then
        game.Players.LocalPlayer.leaderstat.Status.Value + 2
        wait(0.003)
        script.Parent:Destroy()
    end 
end
script.Parent.Touched:connect(onTouch)

2 comments

0

value = value +2

0

???????

2 answers

✓ Accepted answer
1
function onTouch(part)
    local humanoid = part.Parent:FindFirstChild("Humanoid")
    if (humanoid ~= nil) then
game.Players.LocalPlayer.leaderstat.Status.Value = game.Players.LocalPlayer.leaderstat.Status.Value + 2 -- <-- Just Repeat the Line of Code and add + 2 at the end.
        wait(0.003)
        script.Parent:Destroy()
    end
end
script.Parent.Touched:connect(onTouch)

1 comment

0

Thanks too!

Your savior is here man xD (jk don't be mad at me please)

What you want there up, is to get the value you have, and add 2 to the value itself right?

When doing maths, you can also use values from locations. Here, I'll give you an example.

anything.Value = anything.Value + 2 --In here we're adding 2 to the value. You can do the same with multiplying (*), dividing (/), and taking (-).

In your case, the code would be this:

function onTouch(part) 
    local humanoid = part.Parent:FindFirstChild("Humanoid") 
    if (humanoid ~= nil) then
        game.Players.LocalPlayer.leaderstats.Status.Value = game.Players.LocalPlayer.leaderstats.Status.Value + 2
        wait(.003)
        script.Parent:Destroy()
    end 
end
script.Parent.Touched:connect(onTouch)


If this works, please mark as correct, and good scripting! :>

2 comments

0

Thanks bro!

0

Np! ;)

This discussion is preserved as it was. New answers, comments, and votes are closed.