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

How to make a part give a "point" to a leaderboard value? (SOLVED)

Asked by 10 years ago

I have a points/money system in my leaderboard, and I would like to know how to make a part award the player that touches it to gain a "point" in the leaderboard.

How would I do this?

Thank you.

1 answer

Log in to vote
5
Answered by 10 years ago
script.Parent.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        player = game.Players:GetPlayerFromCharacter(hit.Parent)
        player:FindFirstChild("leaderstats").Points.Value = player:FindFirstChild("leaderstats").Points.Value + 1
    end
end)

I fixed it, you're welcome!

Want it to wait before it can be used again? Here

script.Parent.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        player = game.Players:GetPlayerFromCharacter(hit.Parent)
        player:FindFirstChild("leaderstats").Points.Value = player:FindFirstChild("leaderstats").Points.Value + 1
    script.Disabled = true
    wait(5) --Change 5 to anything
    script.Disabled = false
    end
end)
0
It didn't, but thank you for answering! DrCylonide 158 — 10y
0
I fixed it. fireboltofdeath 635 — 10y
0
Haha, I caught that mistake! Thank you so much! DrCylonide 158 — 10y
1
You're welcome! Tell me if you need anything else. I am free to help! fireboltofdeath 635 — 10y
View all comments (12 more)
0
Actually- I do.. is there anyway I could limit the amount of points given to one? Is it a wait function? DrCylonide 158 — 10y
0
Yes. You have to use wait. Though also if you want it to stop it if it is above a certain number then the script Disables fireboltofdeath 635 — 10y
0
Where would I put the wait function? DrCylonide 158 — 10y
0
Just put it before the last end then it will wait until it can be used again. fireboltofdeath 635 — 10y
0
Okay never mind. Here! fireboltofdeath 635 — 10y
0
It didn't work. I tried "wait(4)" before the last end, after the last end.. the part kept rewarding points. DrCylonide 158 — 10y
0
Oh hold on fireboltofdeath 635 — 10y
0
Okay. DrCylonide 158 — 10y
0
Ah, that last edit fixed it. Thank you so much for your time! I'll keep you in mind if I need anything! DrCylonide 158 — 10y
0
Okay. fireboltofdeath 635 — 10y
0
The problem with that is that once the script is disabled, other players will not be able to gain points(unless that is what he wants). There is a better way. Lacryma 548 — 10y
0
I know. You have also use the Local Camera where you'll have to wait until the Local Player can see the brick again. fireboltofdeath 635 — 10y
Ad

Answer this question