I have created a TextBox for admin and have this LocalScript in the client side code. “if string.lower(string.sub(Text, 1, 6)) == “:kick” then
local syntax = string.sub(Text, 7)
if string.lower(syntax) == “me” then
Kick:FireServer(LocalPlayer, “You’re not welcome here at the moment.”)” and for the remote event Kick its "function kickPlayer(player, message)
player:Kick(message)
end
game:GetService(“ReplicatedStorage”).Kick.OnServerEvent:Connect(kickPlayer)" but this code does not work. I’ve tried fixing it with lots of methods and even asked an ai but it didn’t work. DevForum is my last choice.
And the Admin TextBox LocalScript: ```
if string.lower(string.sub(Text, 1, 6)) == ":kick" then
local syntax = string.sub(Text, 7)
if string.lower(syntax) == "me" then
Kick:FireServer(LocalPlayer, "You're not welcome here at the moment.")
The Kick event and LocalPlayer are variables but I think that might be obvious if not then yeah.
You do not need to pass the player as an argument, it is already a default.
So, just remove LocalPlayer argument…
Kick:FireServer("You're not welcome here at the moment.")
Ooh, yeah, if you are trying to pass the target player and not just the local player, add a second parameter to your server script code:
function kickPlayer(player, targetplayer, message)
targetplayer:Kick(message)
end
game:GetService(“ReplicatedStorage”).Kick.OnServerEvent:Connect(kickPlayer)
I did that and it didn’t work. It seems that all that happens is that when I do “:kick me” nothing happens but when I just do “:kick” it kicks me so I’m very confused. The full code is
local Players = game:GetService("Players")
local Kick = game:GetService("ReplicatedStorage"):WaitForChild("Kick")
local Admins = {
JonsStuffMC = true,
FireBoySosa = true
}
local LocalPlayer = Players.LocalPlayer
game:GetService("UserInputService").InputBegan:Connect(function(player)
if Admins[LocalPlayer.Name] and player.KeyCode == Enum.KeyCode.BackSlash then
wait()
script.Parent.Enabled = true
script.Parent:WaitForChild("Frame"):WaitForChild("TextBox"):CaptureFocus()
end
end)
script.Parent:WaitForChild("TextButton").MouseButton1Down:Connect(function()
script.Parent.Enabled = false
end)
script.Parent:WaitForChild("Frame"):WaitForChild("TextBox").FocusLost:Connect(function()
local Text = script.Parent:WaitForChild("Frame"):WaitForChild("TextBox").Text
if Admins[LocalPlayer.Name] then
if string.lower(string.sub(Text, 1, 6)) == ":kick" then
local syntax = string.sub(Text, 7)
if string.lower(syntax) == "me" then
Kick:FireServer("You're not welcome here at the moment.")
elseif string.lower(syntax) == "all" then
for _, player in pairs(Players:GetChildren()) do
Kick:FireServer(player, "You're not welcome here at the moment.")
end
elseif string.lower(syntax) == "other" or string.lower(syntax) == "others" then
for _, players in pairs(Players:GetChildren()) do
if players ~= LocalPlayer then
Kick:FireServer(players, "TestReason")
end
end
else
for _, player in pairs(Players:GetChildren()) do
if string.lower(syntax) == string.lower(string.sub(player.Name, 1, string.len(syntax))) then
Kick:FireServer(player, "TestReason")
end
end
end
end
end
end)
The backslash enables the GUI for admin and the other syntax code is for testing.
Yeah, I haven’t coded lua in a while and I asked an AI if it was correct and it said it was. I also know because I remember coding this in 2019 but I lost the file and quit game development