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

How can I change this script so it only allows players who are in the group?

I am trying to make an application center where only members who are in the group are allowed to fill out an application. When it kicks them how can I also make the top red bar say "Join the group in order to fill out an application"?

local PlayersWhichCanPlay = {PvPNinjaDragon = true, PeerlesslyHinged = true}

game.Players.PlayerAdded:connect(function(Player)
	if not PlayersWhichCanPlay[Player.Name] then
		wait(1)
		Player:Kick()
	end
end)

Please help me, thank you!

1 answer

✓ Accepted answer

You've got the PlayerAdded part figured out, now to make it kick the player if he/she is not in the group, you'll need to check if that player is in the group or not, obviously!

http://wiki.roblox.com/index.php?title=API:Class/Player/IsInGroup

Using information from above link, the script below should kick the player if he/she is not in the group.

group_id = 0 -- Paste your group's ID here
kick_reason = "Please join our group to apply!"

game.Players.PlayerAdded:connect(function(plr) -- When a player joins
if not plr:IsInGroup(group_id) then -- If the player is not in the group then
plr:Kick(kick_reason) -- Kicks the player with specified kick reason
end
end)

Hope this helped, leave a comment below if you need me to answer a question.

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