Check if the player is in the group

Like I want to make a local script that if you leave the group in game the GUI will disappear but IDK if my code is write :confused: I have a 2 codes here.

if Player:IsInGroup(ID) then
	while true do
		wait(3)
		GUI.Frame.EmployeeTeam.Visible = Player:IsInGroup(ID)
	end
end

or

while true do
	wait(3)
	GUI.Frame.EmployeeTeam.Visible = Player:IsInGroup(Employee)
	GUI.Frame.ManagerTeam.Visible = Player:IsInGroup(Manager)
	-- So I don’t need to make a elseif statement over and over
end
1 Like

If players are losing their ranks, its for a good reason.

If you demote a user, kick them from the game.
Cheers!

Check the code again and wdym kick the player if you demoted?

When a player leaves a group, it won’t update instantly in-game. You need to kick them from the game.

Usually, when a player leaves a group, its for a good reason, and they will most likely leave themselves, its not of big concern, if you purposefully demoted them, just invoke a Kick on them.

It updated a bit a time it estimates about 30-50 seconds because I tested it in my alt account.

According to the API
Localscripts can instantly tell if a player has left the group using the normal Functions.
Scripts only update after they left.

NEVER use the client for Rank related events.

In other words, you dont need to check, if you really want to remove whatever GUI they have, just kick them from whatever sever they’re in.

So how do I write my code?

Just ignore this sentence blahblahblah

You dont, its not possible to check if they left the group WHILE they’re playing the game, the game will only know their rank upon joining a server.

:IsInGroup()

So you mean that I can’t make a script thats if the player leaves the group the GUI will get visible = false right?

Yes, the server doesnt know if they left the group until they’ve left the game, its better to kick them

But I’m making this with local script not server script

Refer to this post. Its better to kick them because you cannot trust the client with this kind of thing, having a loop constantly checking for something is a huge HUGE nono

And the Player:IsInGroup is returning true and false too

It will always return true on the server, having checks to see if they left that group while ingame is impossible on the server

No its not

Check this screenshot


Because you’re using a localscript, which does update it live, like i said almost 4 times now

Yeah but I will use a local script to wrute this codes