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

Rank system went wrong, won't change rank?

Asked by
Gingerely 245 Moderation Voter
4 years ago

So, I made the following script, the output did not give any errors, but when my cash value is changed, it does not change my billboard gui nor destroys it...

game.Players.PlayerAdded:Connect(function(plr)
    local cash = plr:WaitForChild("leaderstats").Cash
    local s = game:GetService("ServerStorage")
    local rank = s.Ranks
    local char = plr.Character or workspace.ChildAdded:Wait()
    if plr:WaitForChild("leaderstats").Cash.Value >= rank.Noob.Requirement.Value then
        local noob = rank.Noob:Clone()
        noob.Parent = char.Head
        cash.Changed:Connect(function()
            wait()
            if cash.Value >= rank.Fine.Requirement.Value then
                local fine = rank.Fine:Clone()
                fine.Parent = char.Head
                noob:Destroy()
                cash.Changed:Connect(function()
                    wait()
                    if cash.Value >= rank.Good.Requirement.Value then
                        local good = rank.Good:Clone()
                        good.Parent = char.Head
                        cash.Changed:Connect(function()
                            fine:Destroy()
                            wait()
                            if cash.Value >= rank.Pro.Value then
                                local pro = rank.Pro:Clone()
                                pro.Parent = char.Head
                                good:Destroy()
                            end
                        end)
                    end
                end) 
            end
        end)
    end
end)
0
Noob works once I just start playing the game but the other dont Gingerely 245 — 4y
0
you're using Changed too much, just use it once on wherever you start checking requirements. So after line 5 in your case 0msh 333 — 4y

1 answer

Log in to vote
0
Answered by
0msh 333 Moderation Voter
4 years ago

so it should look something like this (I had to add some stuff to it to test if it works so just ignore them)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
    local l = Instance.new("Folder",plr)
    l.Name = "leaderstats"
    local cash1 = Instance.new("IntValue",l)
    cash1.Name = "Cash"
    local cash = plr:WaitForChild("leaderstats").Cash
    local s = game:GetService("ServerStorage")
    local rank = s.Ranks
    local char = plr.Character
     cash.Changed:Connect(function()
    if plr:FindFirstChild("leaderstats").Cash.Value >= 100 then
        local noob = rank.Noob:Clone()
        noob.Parent = char.Head
            if cash.Value >= 200 then
                local fine = rank.Fine:Clone()
                fine.Parent = char.Head
                noob:Destroy()
                    if cash.Value >= 300 then
                        local good = rank.Good:Clone()
                        good.Parent = char.Head
                            fine:Destroy()
                            if cash.Value >= 400 then
                                local pro = rank.Pro:Clone()
                                pro.Parent = char.Head
                                good:Destroy()
end
end
end
end
end)
end)
end)
0
Ill try it once I get home Gingerely 245 — 4y
Ad

Answer this question