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

My LeaderBoard/GroupRank Leaderboard wont work whats wrong?

Asked by 5 years ago

So I have a leaderboard with 2 IntValue's and a BoolValue for a Group rank, but the BoolValue part won't work with the intValue's, but it does not tell me why. What went wrong. Here is the Script. (P.S. the IntValues still work.)

---Script---

local DataStoreService = game:GetService("DataStoreService")

local myDataStore = DataStoreService:GetDataStore("myDataStore")

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

    local cash = Instance.new("IntValue")
    cash.Name = "Cash"
    cash.Parent = leaderstats
    cash.Value = 0

    local cash = Instance.new("IntValue")
    cash.Name = "Time"
    cash.Parent = leaderstats
    cash.Value = 0

    local Rank = Instance.new("BoolValue", leaderstats)
    Rank.Name = "Rank"
    Rank.Value = player:GetRoleInGroup(5081083)

    local data
    local success, errormessage = pcall(function()
        data = myDataStore:GetAsync(player.UserId.."-cash")
    end)

    if success then
        cash.Value = data
    else
        print("There was a error whilst getting your data")
        warn(errormessage)
    end
end)

game.Players.PlayerRemoving:Connect(function(player)

    local success, errormessage = pcall(function()
        myDataStore:SetAsync(player.UserId.."-cash",player.leaderstats.Cash.Value)
    end)

    if success then
        print("Player Data successfully saved!")
    else
        print("There was a error when saving data")
        warn(errormessage)
     end

end)

1 answer

Log in to vote
0
Answered by 5 years ago
local Rank = Instance.new("BoolValue")
Rank.Name = "Rank"
Rank.Parent = leaderstats
Rank.Value = player:GetRoleInGroup(5081083)

i dont know, must work

Ad

Answer this question