I just made a kick script, and nothing happened in output and it didn't kick me. (I said in the chat /e kick FrostedFlakes67). Here's the code, I hope someone can help.
01 | game:GetService( "Players" ).PlayerAdded:Connect( function (plr) |
02 | if plr.UserId = = game.CreatorId then |
03 | plr.Chatted:Connect( function (msg) |
04 | local lowermsg = string.lower(msg) |
05 | local command = "/e kick " |
06 | if string.sub(lowermsg, 1 ,#command) = = command then |
07 | local PlayerToKick = string.sub(msg,#command,#lowermsg) |
08 | game:GetService( "Players" ):FindFirstChild(PlayerToKick):Kick( "You have been kicked from the game by the game's owner." ) |
09 | end |
10 | end ) |
11 | end |
12 | end ) |
You people are so complicated- #function this,creator.id that. all you need is a detect, then variable finding the name. Like this, put it in a normal script in workspace!
01 | --By: ME, COMMANDERCAUBUNSIA! |
02 | --Tested and worked |
03 |
04 | game:GetService( "Players" ).PlayerAdded:Connect( function (plr) |
05 | if plr.UserId = = game.CreatorId then |
06 | plr.Chatted:Connect( function (msg) |
07 | if string.sub(msg, 1 , 8 ) = = "/e kick " then |
08 | local PlayerToKick = string.sub(msg, 9 ) --if you dont know btw, just puttin begin makes it from that character all the way to the end |
09 | game.Players:FindFirstChild(PlayerToKick):Kick( "You have been kicked from the game by the game's owner." ) |
10 | end |
11 | end ) |
12 | end |
13 | end ) |
After looking carefully, I figured out that there was a space before the player's name, so it was trying to kick " FrostedFlakes67". I just fixed it by doing #command+1, and it is now working, but I changed up the script a lot, and put it as a free model. Here is the model: https://web.roblox.com/catalog/03255077426/redirect Here is the new script:
01 | --People using this script: Do not edit this unless you know what you are doing, this will not work if the game is not published, read "README" for instructions. |
02 | game:GetService( "Players" ).PlayerAdded:Connect( function (plr) |
03 | print ( "Player has joined!" ) |
04 | if plr.UserId = = game.CreatorId then |
05 | print ( "Player is owner!" ) |
06 | plr.Chatted:Connect( function (msg) |
07 | print ( "Player has chatted!" ) |
08 | local lowermsg = string.lower(msg) |
09 | local command = "/e kick " |
10 | if string.sub(lowermsg,- 1 ,#command) = = command then |
11 | warn( "Owner is kicking someone!" ) |
12 | local PlayerToKick = string.sub(msg,#command+ 1 ,#lowermsg) |
13 | print ( "Player to kick is: " ..PlayerToKick) |
14 | game.Players:FindFirstChild(PlayerToKick):Kick( "You have been kicked from the game by the game's owner." ) |
15 | warn( "Owner kicked " ..PlayerToKick.. "!" ) |
16 | end |
17 | end ) |
18 | end |
19 | end ) |
Thanks for all the support!