Thanks you a lot jack!
1 Like
the problem is that when another player enters and his id is not in the admins list he can also kick people
Yeah, I modified the code so that anyone could kick anyone just for testing purposes. I’ll change it back and repost the code.
Try this:
local admins = {
1739689185
} --table with the UserIds of all the admin players
local function CheckIfAdmin(id)
for i, v in pairs(admins) do
if v == id then
return true
end
end
return false
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg) --when they chat
print(msg)
print(msg:lower())
print(admins[player.UserId])
print(player.UserId)
print(admins[533814470])
if msg:match("/kick") and CheckIfAdmin(player.UserId) then -- check if the message includes "/kick", and check if they are in the admin table
for I, v in pairs(game.Players:GetChildren()) do
print(v.Name:lower())--loop through players
if msg:lower():match(v.Name:lower()) then
--check if there name is in the message
v:Kick("An Admin of the game has decided to kick you") --kick them
break --end the loop
end
end
end
end)
end)
2 Likes
It works! thanks a lot! and sorry for the inconvenience
No problem, I’m glad I could help! I really enjoyed trying to get this to work, so thank you for asking the question ! If you have any questions about how this works feel free to ask.
1 Like