Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Kick a player if not in group?

game.Players.PlayerAdded:connect(function(Plyr)
if Plyr:IsInGroup(3384276) or Plyr:IsInGroup(3533917) then
else
--How to kick? I want it so it says a message in the red box. Like, join the group to get in the game.
end
end)

How to kick? I want it so it says a message in the red box. Like, join the group to get in the game. What do I need to write? THIS IS A NORMAL SCRIPT

3 answers

✓ Accepted answer

theres a method of the Player instance that does exactly what you want it to do. here's an example

game.Players.PlayerAdded:Connect(function(player)
	if not player:IsInGroup(3384276) or not player:IsInGroup(3533917) then
		player:Kick("Join the group to get in the game")
	end
end)

by the way, you don't need a pointless if if you're only going to use else, that's why you should use not

2 comments

0

Remember be careful with using not, as it is meant really for boolean values.

1

no, not really

local groupId = 12345678 -- Random Number
local groupRankId = 15 -- Random Number

game:GetService("Players").PlayerAdded:connect(function(player)
	if player:GetRankInGroup(groupId) <= groupRankId then
		player:Kick(player.Name.." is not in group.")
	end
end)

1 comment

0

Use :Connect as :connect is deprecated.

This discussion is preserved as it was. New answers, comments, and votes are closed.