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.