Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Kick a player if not in group?

Asked by 6 years ago
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

Log in to vote
2
Answered by 6 years ago
Edited 6 years ago

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

0
Remember be careful with using not, as it is meant really for boolean values. papasherms 168 — 6y
1
no, not really creeperhunter76 554 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
game.Players.PlayerAdded:connect(function(plr)
    if plr:IsInGroup(3384276) or plr:IsInGroup(3533917) then
    else
        plr:Kick("Join the group to get into the game!")
    end
end)

This should work^

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

0
That 'else' serves no purpose. Use :Connect as :connect is deprecated. awfulszn 394 — 6y
Log in to vote
-1
Answered by 6 years ago
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)

0
Use :Connect as :connect is deprecated. awfulszn 394 — 6y

Answer this question