Use the script: local allowedUsers = {"Player1", "Player2"} -- List of allowed users who can use the :kick command
game.Players.PlayerAdded:Connect(function(player)
-- Function to handle messages in chat
local function onChatted(message)
if message:sub(1, 5) == ":kick" then
local usernameToKick = message:sub(7) -- Get the username after ":kick "
-- Check if the sender is allowed to use the :kick command
if table.find(allowedUsers, player.Name) then
print(player.Name .. " has permission to use :kick.")
local targetPlayer = game.Players:FindFirstChild(usernameToKick)
if targetPlayer then
print(player.Name .. " is kicking " .. targetPlayer.Name)
targetPlayer:Kick("You have been kicked by " .. player.Name)
else
print("Player not found: " .. usernameToKick)
player:SendNotification({
Title = "Error",
Text = "Player not found!",
Duration = 3
})
end
else
print(player.Name .. " does not have permission to use :kick.")
player:SendNotification({
Title = "Error",
Text = "You do not have permission to use this command!",
Duration = 3
})
end
end
end
-- Listen for messages in chat
player.Chatted:Connect(onChatted)
end)
Tags (ignore):
#studiolite #studio