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

Only one leaderstat shows up when I put 2 in the script. Anyone know why?

Asked by
ghxstlvty 133
4 years ago

Salutations, I am trying to have two leaderstats. One with the player's rank, and one with a player's points for the training.

Only the Rank shows up.

This is my current script:

game.Players.PlayerAdded:connect(function(plr)
    local leaderstats = plr:WaitForChild("leaderstats")

local Rank = Instance.new("IntValue",leaderstats)
      Rank.name = "Rank"
      Rank.value = plr:GetRoleInGroup(4853203)

local Points = Instance.new("IntValue",leaderstats)
      Points.name = "Points"
      Points.Value = 0
end)

1 answer

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

Your problem is on line 4, IntValues are number values, not strings.

To fix this, on line 4, change "IntValue" to "StringValue", like so.

local Rank = Instance.new("StringValue",leaderstats)

Final Script

game.Players.PlayerAdded:connect(function(plr)
    local leaderstats = Instance.new("Folder",plr)
    leaderstats.Name = "leaderstats"

    local Rank = Instance.new("StringValue",leaderstats)
    Rank.Name = "Rank"
    Rank.Value = plr:GetRoleInGroup(4853203)

    local Points = Instance.new("IntValue",leaderstats)
    Points.Name = "Points"
    Points.Value = 0
end)

Hope this helped!

0
My script stopped working. :/ ghxstlvty 133 — 4y
0
Combine the scripts. I'll edit my script real quick, just edit the 2 scripts you have into one like how I have mine. killerbrenden 1537 — 4y
0
Just create one script to hold all the values. killerbrenden 1537 — 4y
View all comments (2 more)
0
Thanks so much! ghxstlvty 133 — 4y
0
No problem! killerbrenden 1537 — 4y
Ad

Answer this question