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

Why does my leaderstats dont show up on tab list?

Asked by 4 years ago
Edited 4 years ago

so me and my friend tried making a sword fighting game, and i decided to make a leaderstats for KOs and Wipeouts. I'm really new to coding but i've done leaderstats before and they worked pretty much fine. this script however doesnt, and it didnt give me any errors. so i dont know what to do

script. game.Players.PlayerAdded:Connect(function(plr)

local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = plr

local kos = Instance.new("Folder")
kos.Name = "KOs"
kos.Parent = plr

local wo = Instance.new("Folder")
wo.Name = "Wipeouts"
wo.Parent = plr

plr.CharacterAdded:Connect(function(char)

    local humanoid

    repeat

        humanoid = char:FindFirstChild("Humanoid")
        wait()
    until humanoid
    humanoid.Died:Connect(function()
        wo.Value = wo.Value + 1
        local tag = humanoid:FindFirstChild("creator")
        if tag then
            local killer = tag.Value
            if killer then
                killer.leaderstats.kos.Value = killer.leaderstats.kos.Value + 1
            end
        end
    end)
end)

end)

0
Do not think that just because you post a question, then paste your code, doesn't mean we already know the context. Context is important and it will benefit you. Dovydas1118 1495 — 4y
0
ur right, so me and my friend tried making a sword fighting game, and i decided to make a leaderstats for KOs and Wipeouts. I'm really new to coding but i've done leaderstats before and they worked pretty much fine. this script however doesnt, and it didnt give me any errors. so i dont know what to do gego120 2 — 4y
0
I see the problem. Edit your question to include the description. Dovydas1118 1495 — 4y
0
what is the problem? gego120 2 — 4y
0
I posted an answer. Dovydas1118 1495 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

The problem is your leaderstats needs to have IntValues not Folders, you can't make a folder a value :

23          wo.Value = wo.Value + 1 -- attempts to set a folder value

do this for leaderstats:

game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("Folder") -- Folder for leaderstats
stats.Name = "leaderstats"
stats.Parent = plr

local kos = Instance.new("Intvalue") -- NUMBER VALUE 1
kos.Name = "KOs"
kos.Parent = stats

local wo = Instance.new("IntValue") -- NUMBER VALUE 2
wo.Name = "Wipeouts"
wo.Parent = stats

plr.CharacterAdded:Connect(function(char)


    local humanoid

    repeat

        humanoid = char:FindFirstChild("Humanoid")
        wait()
    until humanoid
    humanoid.Died:Connect(function()
        wo.Value = wo.Value + 1
        local tag = humanoid:FindFirstChild("creator")
        if tag then
            local killer = tag.Value
            if killer then
                killer.leaderstats.kos.Value = killer.leaderstats.kos.Value + 1
            end
        end
    end)
end)
end)
0
thanks, ive already got an answer saying to change "Folder" to "IntValue", that was my mistake but even after correcting it, it still didnt work gego120 2 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

You've added not 1 folder, but 3 folders. For leaderstats, I recommend putting only one folder, and 2 Values (whatever they are, Bool, Number, Int, etc.) Folder does not have a property named 'Value'. Change kos and wo to intvalues.

game.Players.PlayerAdded:Connect(function(plr)
    local stats = Instance.new("Folder")
    stats.Parent = plr
    stats.Name = "leaderstats"

    local kos = Instance.new("IntValue")
    kos.Parent = stats
    kos.Name = "KOs"

    local wo = Instance.new("IntValue")
    wo.Parent = stats
    wo.Name = "Wipeouts"
end)
0
Parent should always be last, that's a good tip for you. VAHMPIN 277 — 4y
0
It doesn't really matter. I've heard people say do Parent after Instance, or do Parent after Name. It doesn't matter. @VAHMPIN . Dovydas1118 1495 — 4y
0
It's best. VAHMPIN 277 — 4y
0
@VAHMPIN I do not want to debate with something that is switched. Dovydas1118 1495 — 4y
View all comments (7 more)
0
not debating, giving a clear fact, i've had 5 years in lua, trust me i know lol. VAHMPIN 277 — 4y
0
@VAHMPIN It doesn't matter really. It's not deprecated (unlike Instance.new() 2nd parameter) also, there are no problems with parenting it first. Dovydas1118 1495 — 4y
0
True but setting properties before parenting is always best as it could detect it with wrong properties. VAHMPIN 277 — 4y
0
@VAHMPIN what do you mean by 'detect it with wrong properties'? Dovydas1118 1495 — 4y
0
thanks, but it's still not showing up on the player list.. i did exactly what u told me to do. gego120 2 — 4y
0
@gego120 What do you mean? It's supposed to show up on the leaderboard. Have you disabled the leaderboard or something? Dovydas1118 1495 — 4y
0
no i haven't, i have no idea what happened. scripts are fine no errors, leaderboard is enabled, API is on. idk gego120 2 — 4y

Answer this question