I made a kick command for my admin commands for my game i made and it didn't work. Under line 22
local function Notify(Player,String,Code) game.ReplicatedStorage.NotificationEvent:FireClient(Player,String,Code) end game.Players.PlayerAdded:Connect(function(Player) if Player:IsFriendsWith(game.CreatorId) or Player.UserId == game.CreatorId then wait(8) game.ReplicatedStorage.NotificationEvent:FireClient(Player,"Welcome "..Player.Name.." you are admin. Prefix is /","E") local prefix = "/" Player.Chatted:Connect(function(Message) local sub = string.sub(Message,1,1) if sub == prefix then local split = string.split(Message,prefix) local lower = string.lower(split[2]) if lower == "r6" then require(script.R6).load(Player.Name) elseif lower == "cmds" then Notify(Player,"Commands right now are /r6 and /reset and /lustris Note : You have to do /r6 to do /lustris","E") elseif lower == "reset" then Player:LoadCharacter() elseif lower == "lustris" then require(4758620694).load(Player.Name) elseif lower == "kick" then local split2 = string.split(Message," ") if game.Players:FindFirstChild(split2[2]) and split2 ~= "all" and split2 ~= "others" then game.Players:FindFirstChild(split2[2]):Kick("You have been kicked by "..Player.Name) end if string.lower(split2[2]) == "all" then for i, v in pairs(game.Players:GetChildren()) do v:Kick("You have been kicked by "..Player.Name) end elseif string.lower(split2[2]) == "others" then for i, v in pairs(game.Players:GetChildren()) do if v.Name ~= Player.Name then v:Kick("You have been kicked by "..Player.Name) end end end elseif lower ~= "cmds" or lower ~= "reset" or lower ~= "lustris" or lower ~= "kick" or Message ~= nil then require(script.Loadstring)(split[2])() end end end) end end)
After separating the prefix from the rest of the message as shown in your first split variable you proceed to use string.lower to turn the remaining string into lowercase letters. Well the thing is that the remaining string you have left after using string.split doesn't match with your if statements for instance
local split = string.split("/kick DeUltimate23","/") local lower = string.lower(split[2]) print(lower)
I am pretty sure this would print (kick DeUltimate23) and as you see it doesnt match your if statements.
One way to fix this is using string.find or split the whitespace from the command from message after the first split.
The string.find method can be done like this
if string.find(string.lower(split[2]),"kick") then --Do your thing here end
Hopefully you understood my explanation, and it might also be that I am wrong or there is an easier solution to this. Anyways good luck