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

Why doesn't my script want to kick a person from a given group on roblox?

Asked by 3 years ago

He wants the player after he joins the game to kick him out of the group with the given IP. I entered my group to which I belong and it doesn't work, what did I do wrong?

while true do
    wait(3)
    local Player = game:GetService("Players").LocalPlayer
    local ID = 11260813
    if  Player:IsInGroup(ID) then
        Player:Kick("You are kicked for being in illegal group")
    end
end

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

This is a ServerScript in ServerScriptService which is best for ServerScripts

local illegalGroups = {1234567890, 987654321, 098765432}

game.Players.PlayerAdded:Connect(function(client)
    for index, value in pairs(illegalGroups) do
        if client:IsInGroup(value) then
            client:Kick("You are kicked for being in illegal group")
        end
    end
end)

--[[
First, there is an array with all the illegal group IDs.
(Those ID's in the array are not actual group ID's there're just to demonstrate)

Next, I used a PlayerAdded event and connected it to a function.
(That parameter called 'client' means the client that got added to the Players Service basically means when a client joins the server)

After that, it will loop through the array.

Each iteration will check if the player is in that illegal group.
If they are then it will kick them otherwise, it will do nothing
]]

Any questions? Just reply to my answer

Ad

Answer this question