End project, I want this to be able to tell me how many high ranks are in a server. I just cant figure out how to implement group ID, and count only a certain rank or above. Any help would be much appreciated.
while wait()do if game.Players.NumPlayers==1 then script.Parent.Text= ""..game.Players.NumPlayers.." player" else script.Parent.Text= ""..game.Players.NumPlayers.." players" end end
Since it doesn't look like you put attempt into using the Group functions provided, I will give you some instructions on how to create the script you're looking for.
function GetGroupMemebers()
where no arguments are necessarily required.for i,v in pairs(game.Players:GetPlayers()) do
:GetRankInGroup()
on the player using the variable v defined in the for loop. v can be changed to whatever you want when you make the loop. Within the GetRankInGroup method, you want to put the Group's ID so the script knows where to look. Then with the if then statement you want to compare the result which the function will provide to the rank you want the user to have using greater than or equal to condition >=
.Within that if-then statement, you're going to want to add on to how many HRs you have.
if Condition then hr = hr + 1 end
Of course, not everyone will be a High Rank. You will want to add elseif inside the if-then statement. This will tell the script, alright since the player isn't a HR, let's see if they can pass this condition. With the elseif condition you will want to simply use IsInGroup()
to determine if that player is in the group or not. Like with GetRankInGroup, you still need the GroupId as an argument to the method.
Depending on what you want to do, at the end of the function you may want to return the results of the code or edit a GUI.
function x() --CodeHere TextLabel.Text = "There are " .. hr .. " High Ranks and " .. groupmemembers .. " group members." end
Now, I would not recommend using a while loop as this is inefficient when we have events which can tell us if a player has left or joined.
Outside of the function at the bottom of the script you will want to add the PlayerAdded and PlayerRemoving events. With events we can call a function when a player is joining the game or leaving.
game.Players.PlayerAdded:connect(x) game.Players.PlayerRemoving:connect(x) x() --Add this if you plan on going a Gui route as there may not be any joining or leaving players in a respawn.
At this point you should be set. I would just recommend you put more effort into your script and question content next time as this may be seen as a request. Scripting Helpers does not take requests and this was a long list of instructions to write up. If you have any questions, feel free to ask. If you finished the instructions and the script isn't working make a new question on the site.
This should help you out! :)
http://wiki.roblox.com/index.php?title=API:Class/Player/GetRankInGroup