I’m trying to make a script that kicks the player and posts a system message in the chat
--Variables
local player = game.Players.LocalPlayer
local canKick = {"TheXEternalXSlayer"}
--Actual script
game.Players.PlayerAdded:Connect(function(plr)
for _, c in pairs(canKick) do
if plr.Name == c then
plr.Chatted:Connect(function(msg)
if string.sub(msg,1,5) == "/kick" then
local pl = game.Players:FindFirstChild(string.sub(msg,7))
if pl then
pl:Kick("RAC banned from secure server") --You can edit this message to what you prefer.
game.StarterGui:SetCore("ChatMakeSystemMessage", {
Text = "Player" ..player.Name.. "left the game [RAC banned from secure server]";
Color = Color3.fromRGB(255, 151, 151);
Font = Enum.Font.ArialBold;
FontSize = Enum.FontSize.Size18;
})
end
end
end)
end
end
end)
The script kicks the player but the system message doesn’t send. what am I doing wrong?
I’ve tried switching the message before the kick but that just makes neither of them work. I can’t think of any other way to fix the script.