I still wouldn’t copy paste a big if statement and call GetRankInGroup many times, it’s inefficient. I’d do this:
local groups = {
[groupId]={0,5,55,255} -- comma separated list of rank ids
} -- This supports any number of groups and any number of ranks
for gId, ranks in pairs(groups) do
local rankInGroup = player:GetRankInGroup(gId)
if table.find(ranks, rankInGroup) ~= nil then
print("Player has a rank that's in the table")
-- Add the UI here, you can delete the print
break
end
end
1 Like
That code looks much better. You can rely on it. @TwoBrakeRBX try this one.
I would rather use your script. The only thing is that it does not even work. When I use it with 2 ranks, it does nothing.
Are there any errors in the output?
22:57:51.952 ServerScriptService.Script:22: Expected ‘end’ (to close ‘function’ at line 4), got ; did you forget to close ‘then’ at line 15? - Studio - Script:22
Add a extra end)
at the bottom of the script. That’s the issue.
It actually worked, will I have to add another end) every time I add another rank?
No.
If you experience some more errors, try getting a bit better at Lua. It seems you’re a bit of a beginner.
If you keep doing the same thing you were doing when copying and pasting then you won’t get errors.
Thank you so much for helping me! I am trying to become more advanced at scripting in Roblox.
1 Like