So, we are currently trying to write a chat command system, and we got the :kick command in the code below working:
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local split = msg:split(" ")
if split[1] == ":kick" then
local targ = game.Players:FindFirstChild(split[2])
local reason = split[3]
if targ then
if reason then
targ:Kick(reason)
else
targ:Kick("No reason provided.")
print("User kicked | User: "..targ)
end
elseif split[1] == ":ban" then
local targ = game.Players:FindFirstChild(split[2])
local reason = split[3]
if targ and reason then
targ:Kick("You've been banned from "..game.Name.."\n Reason: "..reason)
print("User Banned | User: "..targ "Reason: "..reason)
elseif split[1] == ":kill" then
local targ = game.Players:FindFirstChild(split[2])
targ.Character.Head:remove()
print("User killed | User: "..targ)
else
warn("Not a command")
end
end
end
end)
end)
But the problem is, after the check for the kick command is run, it does not run the elseif’s. We have tried everything, but we do not get anything in the output. No errors or prints, nothing.
If anyone knows why neither the ban nor the kill command are working, please let me know, as me and @WakeTheDev have tried everything to fix it.
(Also I’m aware that it is targ:Kick()
and not a datastored ban, we just have it as that for testing purposes.)