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

My ranking system doesn't work (test), any answers on why?

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 = 'Private'
	
	local xp = Instance.new('IntValue',leaderstats)
	xp.Name = 'XP'
	xp.Value = 0
	
	while wait(3) do
		
		xp.Value = xp.Value + 1
		
	end
	
	if (xp.Value >= 10) then
		
		rank.Value = 'Corporal'
		
	end
	
end)

1 comment

0

Your script will never hit line 20 and below, as wait(3) on line 14 will always be true, causing an infinite loop.

1 answer

Pretty easy answer. Change everything underneath xp.Value = 0 to (explanation underneath script):

while wait(3) do
	xp.Value = xp.Value + 1 -- Random note but Lua seriously needs to add += or something like that
	if xp.Value >= 10 then
		rank.Value = "Corporal"
	end
end

What we do here is check every time the loop runs if xp.Value is greater than or equal to 10. If it is, we rank up the player. We then continue to increase the player's xp.

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