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

Is there a more efficient way of doing this?

Asked by 9 years ago

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)
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. Perci1 4988 — 9y
0
I had elseifs, but it crashed. Still didn't work, though. SimplyRekt 413 — 9y

1 answer

Log in to vote
0
Answered by
A9X 10
9 years ago

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

Ad

Answer this question