I’m trying to blacklist commands from the HD Admin Command set by kicking people when they use them. One of the commands I am trying to do this to is, ironically, the ;kick command. I want to make it so that if the message in chat contains ;kick, it will kick them from the game. And I also want to make it so that if the User ID is mine, it won’t kick me from the game as I am the owner. I’ve already blacklisted some commands, but the “if etc. and not player.UserId == (my user id)” does not work, and it kicks me when I use the commands.
Code:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(m)
-- i don't want this to be bypassed with ;btools/buildingTools me or something.
if m == ";btools" or ";buildingTools" and player.UserId == not 909473056 then
player:Kick()
end
-- under here, i need to put the ;kick, ;gear and other commands.
end)
end)
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(m)
-- i don't want this to be bypassed with ;btools/buildingTools me or something.
if m == ";btools" or m == ";buildingTools" and player.UserId ~= 909473056 then
player:Kick()
end
-- under here, i need to put the ;kick, ;gear and other commands.
end)
end)
edit: i strongly recommend the usage of m:lower() to flag those commands even if they’re written in all caps or out of order. i’d also recommend string.find or string.sub instead of matching the exact message in the case of those that require multiple arguments such as kick.
I know. I was looking into using string.sub and lower() for the command checking but I don’t know how to do it. So I would probably need an example first. PS: The code you supplied above does not work. It has trouble with my UserID.
That is not working either. My code I had in the thing was:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(m)
-- i don't want this to be bypassed with ;btools/buildingTools me or something.
if m == ";btools" or ";buildingTools" then
if player.UserId == (909473056) then
print("Player is the owner, and bypassed blacklisted command.")
else
player:Kick("\n\nThe reason for your kick from the game is as follows.\n\nThat command is blacklisted. You have been kicked from the game as a result of you using it. This is a simple punishment to stop players from using it, not a warning.")
end
-- under here, i need to put the ;kick, ;gear and other commands.
end
end)
The problem here is the entire script does not work. It does not kick people. I don’t know if I formatted it or something correctly.
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(m)
if string.sub(string.lower(m), 1, 7) == ";btools" or string.sub(string.lower(m),1, 14) == ";buildingtools" then --check if the message contains the string
if player.UserId == 909473056 then -- if the player matches the owner, then let the command through
print("Command successfully executed.")
else -- otherwise, kick them
player:Kick("Insufficient permissions.")
end
end
end)
end)