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

Is there a more efficient way of doing this?

This script looks, and probably is, very inefficient. And it doesn't want to work. Any help?


game.Players.PlayerAdded:connect(function(plr)
	local rank = Instance.new("StringValue", plr)
		rank.Name = "Rank"
	local stats = plr:WaitForChild("leaderstats")
	local rep = stats:WaitForChild("Reputation")
	
	--POSITIVE
	
	if rep then
		print("Found "..plr.Name.."'s reputation.")
	end
	
	if rep.Value <= 99 then
		rank.Value = "Civilian"
	end
	
	if rep.Value >= 100 and rep.Value < 999 then
		rank.Value = "Constable"
	end
	
	if rep.Value >= 1000 and rep.Value < 2499 then
		rank.Value = "Vigilante"
	end
	
	if rep.Value >= 2500 and rep.Value < 4999 then
		rank.Value = "Deputy"
	end
	
	if rep.Value >= 5000 and rep.Value < 9999 then
		rank.Value = "Lawman"
	end
	
	if rep.Value >= 10000 and rep.Value < 14999 then
		rank.Value = "Guardian"
	end
	
	if rep.Value >= 15000 and rep.Value < 24999 then
		rank.Value = "Nobile"
	end
	
	if rep.Value >= 25000 and rep.Value < 99999 then
		rank.Value = "Hero"
	end
	
	if rep.Value >= 100000 and rep.Value < 249999 then
		rank.Value = "Omeaga Hero"
	end
	
	if rep.Value >= 250000 then
		rank.Value = "Saint of Sanctuary"
	end
	
	--NEGATIVE// WILL DO THE SAME TO THIS//

--	if rep.Value <= -1 then
--		rank.Value = "Civilian"
--	end
--	
--	if rep.Value <= -5 then
--		rank.Value = "Felon"
--	end	
--	
--	if rep.Value <= -100 then
--		rank.Value = "Thug"
--	end
--	
--	if rep.Value <= -1000 then
--		rank.Value = "Outlaw"
--	end
--	
--	if rep.Value <= -2500 then
--		rank.Value = "Bandit"
--	end
--	
--	if rep.Value <= -5000 then
--		rank.Value = "Marauder"
--	end
--	
--	if rep.Value <= -10000 then
--		rank.Value = "Villian"
--	end
--	
--	if rep.Value <= -15000 then
--		rank.Value = "Hitman"
--	end
--	
--	if rep.Value <= -25000 then
--		rank.Value = "Assassin"
--	end
--	
--	if rep.Value <= -100000 then
--		rank.Value = "Serial Killer"
--	end
--	
--	if rep.Value <= -250000 then
--		rank.Value = "Destroyer of Worlds"
--	end
	
end)

2 comments

0

Well you certainly should use elseif instead of all those ifs, but I don't know any super clever way to make it much shorter. I hope someone else does.

0

I had elseifs, but it crashed. Still didn't work, though.

1 answer

The way you're doing it is probably the most efficient, sorry.

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