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

How do you make a script so when you touch a part it will change the leaderboards number by 1?

Asked by 10 years ago

Why won't it work?

if Part.Touched == true then
score.Value = FirstValue + 1
end

1 answer

Log in to vote
1
Answered by
TofuBytes 500 Moderation Voter
10 years ago

Good attempt, but there's a lot more than that for your script. You would put this script into your parts so you can give them a score.

Place inside your parts:

local Pressed = false --We need to provide a local variable.

script.Parent.Touched:connect(function(hit)
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then --We are checking if it's a player.
        if not Pressed then --We used that variable above if it's not touched.
        p = game.Players:GetPlayerFromCharacter(hit.Parent) --We gather the player who touched the part.
        p.leaderstats['Score'].Value = p.leaderstats['Score'].Value + 1 --We gather their leaderstats and look for 'Score'. If you have another you can name 'Score' to the other Value.
        Pressed = true --We turn true on and it will pause because we're checking for the false state.
        wait(2)--Wait 2 seconds and then it turns on. (You can change this number to an amount of seconds you want it to wait.)
        Pressed = false --Then we turn the brick back on to award a Score point.
        end
    end
end)

Hopefully this will help you! :) Good luck!

Make sure to accept the answer if it works!

0
Works!But i don't know why my script didn't work iluvmaths1123 198 — 10y
0
You were missing the functionality of the script. 'if Part.Touched == true then' doesn't fit the requirements for it. TofuBytes 500 — 10y
Ad

Answer this question