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.
game:GetService("Players").PlayerAdded:Connect(function(plr) if plr.UserId == game.CreatorId then plr.Chatted:Connect(function(msg) local lowermsg = string.lower(msg) local command = "/e kick " if string.sub(lowermsg,1,#command) == command then local PlayerToKick = string.sub(msg,#command,#lowermsg) game:GetService("Players"):FindFirstChild(PlayerToKick):Kick("You have been kicked from the game by the game's owner.") end end) end 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!
--By: ME, COMMANDERCAUBUNSIA! --Tested and worked game:GetService("Players").PlayerAdded:Connect(function(plr) if plr.UserId == game.CreatorId then plr.Chatted:Connect(function(msg) if string.sub(msg,1,8) == "/e kick " then 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 game.Players:FindFirstChild(PlayerToKick):Kick("You have been kicked from the game by the game's owner.") end end) end 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:
--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. game:GetService("Players").PlayerAdded:Connect(function(plr) print("Player has joined!") if plr.UserId == game.CreatorId then print("Player is owner!") plr.Chatted:Connect(function(msg) print("Player has chatted!") local lowermsg = string.lower(msg) local command = "/e kick " if string.sub(lowermsg,-1,#command) == command then warn("Owner is kicking someone!") local PlayerToKick = string.sub(msg,#command+1,#lowermsg) print("Player to kick is: "..PlayerToKick) game.Players:FindFirstChild(PlayerToKick):Kick("You have been kicked from the game by the game's owner.") warn("Owner kicked "..PlayerToKick.."!") end end) end end)
Thanks for all the support!