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

Possible to select a array of numbers easily, like 1 to 5?

Asked by 6 years ago
Edited 6 years ago

Im trying to make a group rank system but I want my code to look nice. Problem is when I try to set it so if your a certain rank you'll get a certain morph I have to do 1 and 2 and 3 and 4 which is just redundant. And it would require me to write numbers like 30 times between gaps of permissions. Any other way?

1player = game.Players.LocalPlayer
2Group = player:GetRankInGroup(889994)
3if player:GetRankInGroup(889994) == 1-3 then
4    print("Hey")
5 
6end

There ^ I was trying to select 1 to 3 My other way

1player = game.Players.LocalPlayer
2Group = player:GetRankInGroup(889994)
3if player:GetRankInGroup(889994) == 1 and 2 and 3 and 4 and 5 then
4    print("Hey")
5 
6end
1
Please post a script. We cannot read your mind, if you want help, help us first. User#19524 175 — 6y
0
I just want to select numbers easily like 1 to 5 meaning 1,2,3,4 and 5. numercookie13246 11 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago

Yes!

You can create a table with those numbers, seperated by a , and use in pairs to do what you want!

01local numbers = {1, 2, 3, 4, 5}
02 
03for _,v in pairs(numbers) do
04    player = game.Players.LocalPlayer
05    Group = player:GetRankInGroup(889994)
06 
07    if player:GetRankInGroup(889994) == v then
08        print("Hey")
09    end
10end
Ad

Answer this question