Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Rank system went wrong, won't change rank?

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)

2 comments

0

Noob works once I just start playing the game but the other dont

0

you're using Changed too much, just use it once on wherever you start checking requirements. So after line 5 in your case

1 answer

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)

1 comment

0

Ill try it once I get home

This discussion is preserved as it was. New answers, comments, and votes are closed.