Not joined group, can't join!

Hello you guys. After a long time, I have finally posted a tutorial. Tutorial: If your not in group, you can’t play the game.

How to do it:
If you want to watch the youtube video, you can watch it below or get an explaination with me

First, you make a script on serverscriptservice and name it “KickGameGroup”
Next, you type the code in the video into the script (DONT ADD THE FIRST LINE)
Where it says IsInGroup(0) paste the group id there.

Explaination

The code will detect if the player is in the group you’ve given it by using IsInGroup
If your in the group, it will say “PLAYER NAME is in group” because we typed in

print(player.Name, "is in group")

The code below will kick the player if they are not in the group

else
print(player.Name, "is not in group. He has been kicked from the game")
player:Kick("Join our group to play the game")

Thanks for reading!

If you guys were here just to copy and paste the script, here it is!

--By @iscomessi8
--ServerScriptStorage
--Normal Script! Name it KickGameGroup

 local Player = game:GetService("Players") --For the print message that is later

game.Players.PlayerAdded:Connect(function(player) -- PlayerAdded Connect Function
	if player:IsInGroup(0) then  --Detects if player is group using IsInGroup copy your group id and paste it on the 0
		print(player.Name, "is in group") --Print if in group
	else
		player:Kick("You are not in group, pls join group to play game") --Kick Message
		print(player.Name, "is not in group. He is kicked from the game") --Print if player is not in group

	end
end)

If you want to(This is for noobies across the world)
If you want, you can also do multiple groups in one script.
Example:

--By @iscomessi8
--ServerScriptStorage
--Normal Script! Name it KickGameGroup

 local Player = game:GetService("Players") --For the print message that is later

game.Players.PlayerAdded:Connect(function(player) -- PlayerAdded Connect Function
	if player:IsInGroup(1, 2) then  --Detects if player is group using IsInGroup copy your group id and paste it on the 0
		print(player.Name, "is in group") --Print if in group
	else
		player:Kick("You are not in group, pls join group to play game") --Kick Message
		print(player.Name, "is not in group. He is kicked from the game") --Print if player is not in group

	end
end)

On the IsInGroup line, add a comma after your first group and insert your group id there.

6 Likes

You can also restrict game access without any script, through Roblox’ collaborate feature.

You can make your game private and use Collaborate to only give permissions to all members in the group.

4 Likes

I’m not sure the point of being able to not play because of not joining group but on the good side, you just brought about the awareness of the function.

player:isInGroup

People who were unaware of this function could use that for other reasons!

2 Likes

You don’t need to do that, you go in “Configure place”, then you active: Who can play the game: “Group members”. (That’s not exactly what will be print but almost.)

1 Like

What about the custom kick and print messages? You can’t do that without a script.
Plus, this script can do it for any group across the roblox community.

Like I said to @xChris_vC , you can’t create a custom kick and print message without a script. Roblox hasn’t made it allowable to do any group. This script can do it to any group but without the script, you can only do it with your own group.

1 Like

It’s just a script. I just made it for fun. I don’t know why people would use it. I just made it for a tutorial.

It is important to have fun when developing so good that you enjoyed it

3 Likes
  1. There’s no point for a custom kick message whatsoever, as it’s going to be some form of “join the group”

  2. It’s kind of scummy/unfair to be farming visits from people who are joining without being in the group

  3. Unless you’re running something you shouldn’t be (eg a condo) you generally won’t need to be approving access for groups that aren’t yours/aren’t handled by you

1 Like

Edit
Made an edit to the tutorial for all the noobies of coding

I can think of plenty of communities where the game needs to be non-public, but allow access to multiple groups. Mostly in the military/ronation/clan genres.

Well, some people may find this kind of useful.
They could use it as a way to make their game only for testers/people who join their group
Example:

But the example you’re showing us can easily be done in the configure place.

3 Likes

Oh, well I never knew about that, It never pops up to me.

You can read this. It will tell you how to do it.

why are you calling player service and then don’t use it, replace:

game.Players.PlayerAdded with

Player.PlayerAdded

my bad, I forgot to remove it. I was just dumb. I didn’t want to record the whole thing again.