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

Why won't my leaderstat go up?

Asked by 9 years ago

This is in a local script, but it sort of needs to be in a local script so I'm confused what to do. is it the square brackets? Please help.

--Your wins.
local yw = game.Players.LocalPlayer.leaderstats.Wins.Value
--Your losses.
local yl = game.Players.LocalPlayer.leaderstats.Losses.Value
--Button.
local button = script.Parent["Flip a card"]
--Your Move.
local ym = script.Parent["Your move"]
--Their Move.
local tm = script.Parent["Their move"]
--Winner board.
local wb = button.Label


--Function for button.
function pressed()
    --Your move number.
    local ymn = math.random(1,10)
    --Their move number.
    local tmn = math.random(1,10)
    --Labelling.
    ym.Text = ymn
    tm.Text = tmn
    --Logic.
    if ymn > tmn then
        wb.Text = "You win!"
        yw = yw + 1
    else
        wb.Text = "You lost!"
        yl = yl + 1
    end
end


--binding function
button.MouseButton1Down:connect(pressed)

When I put it into a Normal script and modded it it still wouldn't work

--Your wins.
local yw = script.Parent.Parent.Parent.Parent.leaderstats.Wins.Value
--Youre losses.
local yl = script.Parent.Parent.Parent.Parent.leaderstats.Losses.Value
--Button.
local button = script.Parent["Flip a card"]
--Your Move.
local ym = script.Parent["Your move"]
--Their Move.
local tm = script.Parent["Their move"]
--Winner board.
local wb = button.Label


--Function for button.
function pressed()
    --Your move number.
    local ymn = math.random(1,10)
    --Their move number.
    local tmn = math.random(1,10)
    --Labelling.
    ym.Text = ymn
    tm.Text = tmn
    --Logic.
    if ymn > tmn then
        wb.Text = "You win!"
        yw = yw + 1
    else
        wb.Text = "You lost!"
        yl = yl + 1
    end
end


--binding function
button.MouseButton1Down:connect(pressed)

1 answer

Log in to vote
1
Answered by
Tkdriverx 514 Moderation Voter
9 years ago

It's probably because the values don't even exist. Use a LocalScript. If you have a script (server Script) adding them, try using game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Wins"), etc. Also, remove the .Value and re-add it where you're trying to set the values (yw = yw + 1 to yw.Value = yw.Value + 1). This will actually set the values of them.

Ad

Answer this question