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

Leaderboard point issues. So how do I do this?

Asked by 7 years ago
Edited 7 years ago

How do I make it so when a player touches a brick, it gives them gold? here is my leaderboard script by the way:

function playerAdded(plr)

   local stats = Instance.new("IntValue", plr)
   stats.Name = "leaderstats"

   local cash = Instance.new("IntValue", stats)
   cash.Name = "Gold"
   cash.Value = 50

end

game.Players.PlayerAdded:connect(playerAdded)

Also, how do I make it so when a player also touches a brick, it takes away gold?

1 answer

Log in to vote
0
Answered by
blowup999 659 Moderation Voter
7 years ago
local howMuchGold = 50

part.Touched:connect(function(part)
    local plr = game.Players:GetPlayerFromCharacter(part.Parent)
    if plr then
        plr.leaderstats.Gold.Value = plr.leaderstats.Gold.Value + howMuchGold
    end
end)

If you want it to decrease then make howMuchGold negative

Ad

Answer this question