I want my kick command to be able to kick the said player and at the same time have an option to be able to say a reason as well but, I cant seem to be able to get the player and the reason separately. Here is my script:
function Run(args)
script.Parent.Parent.exe.SE:FireServer("",args)
end
game:GetService("UserInputService").InputBegan:Connect(function(e,gpe)
if e.UserInputType == Enum.UserInputType.Keyboard then
if e.KeyCode == Enum.KeyCode.Return then
local text = script.Parent.Text
local txt = script.Parent
if string.find(text:sub(1, 4), "kick") and string.find(text:sub(6, #text), ".+") then
txt.Text = ''
local user = text:sub(6, #text)
local reason = "No Reason Given."
if string.find(text:sub((6 + #user), #text), ".+") then
reason = text:sub((6 + #user), #text)
end
if user:lower() == "others" then
for _,plrs in pairs(game.Players:GetChildren()) do
if plrs.Name ~= game.Players.LocalPlayer.Name then
Run("game.Players." .. plrs.Name ..":Kick('" .. reason .. "')")
end
end
elseif user:lower() == "all" then
for _,plrs in pairs(game.Players:GetChildren()) do
Run("game.Players." .. plrs.Name ..":Kick('" .. reason .. "')")
end
end
for _,plr in pairs(game.Players:GetChildren()) do
if (plr.Name:lower():sub(1,#user) == user) then
Run("game.Players." .. plr.Name ..":Kick('" .. reason .. "')")
end
end
end
end
end
end)
i have used prints in parts of the script and they have been removed, the result I'm getting is the user and reason together when I try to print local user. Please someone help me because I don't know what to do at this point.

1 comment
You can use string.split(STRINGTOSPLIT, " "), string.split() returns as a table, so you can loop through it.