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

Wats wrong with my leaderboard???

Asked by 10 years ago

plz tell me wats wrong! the person I made this for said it didnt show up, and then I tested in solo mode, and no values showed up, or any words on the leaderboard... and as well as am at asking yas about this leaderboard... the guy wants to know if its possible for this to add points every 12/24 hours even if someone isnt online... and he asked if I could make it saveable so that he wouldnt need to get a different script, cos he wanna have it all in 1 script... thnx for reading...

local stats = {"Points", "RW", "TDD"}

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"
    for _, stat in pairs(stats) do
        Instance.new("IntValue", leaderstats).Name = stat 
    end
end

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"
    local money = Instance.new("IntValue", leaderstats)
    money.Name = "Points"
    money.Value = 0
end)

while wait(3600) do 
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
            Player.leaderstats.Money.Value = Player.leaderstats.Money.Value +100
        end
    end
end

2 answers

Log in to vote
0
Answered by
AxeOfMen 434 Moderation Voter
10 years ago

There are a couple of problems with your code. The primary problem is that you are missing a closing parenthesis on the first PlayerAdded method. This constitutes a syntax error and prevents ROBLOX from understanding your code. The second is that you are creating the "leaderstats" model twice.

The following code is tested:

local stats = {"Points", "RW", "TDD", "Money" }

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"
    for _, stat in pairs(stats) do
        local sv = Instance.new("IntValue", leaderstats)
        sv.Name = stat
    end
end)

while wait(3600) do
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
            Player.leaderstats.Money.Value = Player.leaderstats.Money.Value +100
        end
    end
end

Create a new question to ask about adding points every 12/24 hours.

[Edit] To answer your questions, you can remove and add any values to the stats table, so yes you can remove "Money", however notice that in the final while loop, the money value is what gets incremented. If you remove money, you probably want to change that to Points where it says Money.

You do not need a space between "Money" and }

Updated:

local stats = {"Points", "RW", "TDD"}

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"
    for _, stat in pairs(stats) do
        local sv = Instance.new("IntValue", leaderstats)
        sv.Name = stat
    end
end)

while wait(3600) do
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
            Player.leaderstats.Points.Value = Player.leaderstats.Points.Value +100
        end
    end
end
0
doees it have to be money in it? cos I made this to be just them 3 LokHsuLi 10 — 10y
0
and does there have to be a space between the last leaderstats and }??? LokHsuLi 10 — 10y
0
I mean between " and } LokHsuLi 10 — 10y
0
he said it owrks perfect :D thnx a lot bro :D :) =) LokHsuLi 10 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model", player)
    leaderstats.Name = "leaderstats"
    local money = Instance.new("IntValue", leaderstats)
    money.Name = "Points"
    money.Value = 0
    for _, stat in pairs(stats) do
       local sv = Instance.new("IntValue", leaderstats) --sv = statvalue
      sv.Name = stat
    end
end

while wait(3600) do 
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player:FindFirstChild("leaderstats") then
            Player.leaderstats.Money.Value = Player.leaderstats.Money.Value +100
        end
    end
end

You dont need 2 PlayerAdded events.

0
still no stats show up :( LokHsuLi 10 — 10y
0
are you testing in solo mode if so go to server mode by clicking F7 then when it gets to the server press ALT+F7 DragonSkyye 517 — 10y
0
still dosnt work :( and btw, could u tell me, y is the camera always messed up, ur only allowed to view player from a side and alloed to go sideways only? and theres a part called player1center or something like that... LokHsuLi 10 — 10y

Answer this question