I want to make a kick message so if the game stops it says Server Has Been Stopped.
and not You were kicked from this game: Server Has Been Stopped.
i am unable to get this to happen can i get some help thanks! Code i own
elseif m:sub(1, 6):lower() == "/stop " then if p.UserId == 261477936 then RAW("Shutting Down This Server!") wait(1) RAW("10") wait(1) RAW("9") wait(1) RAW("8") wait(1) RAW("7") wait(1) RAW("6") wait(1) RAW("5") wait(1) RAW("4") wait(1) RAW("3") wait(1) RAW("2") wait(1) RAW("1") wait(1) for i, v in pairs(game.Players:GetPlayers()) do v:Kick(m:sub(7)) end end
btw thats apart of my custom chat RAW() fires all clients with the message inside.
edit:1.) i am unable to show my entire code for privacy reasons
2.) i only know \n which makes a new line in the kick message thats the only command i know for the messages
‘3.) The current way is when an admin says /stop the message after is the kick message but I want it to say the kick message but without the You have been kicked: in it
You can create a custom kick message through the Kick function on a Player object as it has one argument: the message.
For example, game.Players.playername:Kick("message") would display "You have been kicked from this Game: message" when kicked.
Looking at your code, I'm assuming that when a Player is kicked, it would say the player's name instead. If the command is intended to shut down the entire server, then the m:sub(7) argument is completely unnecessary. Instead of writing m:sub(7), you can just write the message you intended to write.
For example,
elseif m:sub(1, 6):lower() == "/stop " then if p.UserId == 261477936 then RAW("Shutting Down This Server!") for i = 10, 1, -1 do --I added a for loop to reduce the repetitiveness within your script; this is untested wait(1) RAW(tostring(i)) end for i, v in pairs(game.Players:GetPlayers()) do v:Kick("The server has been shut down.") end end
In this example, when a Player is kicked, the message will display "You have been kicked from this Game: The server has been shut down." Customize that to what you intend to write.
I'm not 100% sure what you wanted to do, but this script worked for me.
ServerScript inside of ServerScriptService
game.Players.PlayerAdded:Connect(function(player) player.Chatted:Connect(function(msg) if msg:sub(1,6) == "/stop " then if player.UserId == 33788911 then -- Change UserId for _,plr in pairs(game:GetService("Players"):GetChildren()) do --// You Can Do :GetChildren() or :GetPlayers() - Both Work The Same Way plr:Kick("\n"..msg:sub(7)) end end end end) end)
If this works, let me know by taking this as the answer. If it doesn't work, comment what error occurs.
The only difference is that I shortened your version down.
~killerbrenden
You didn't understand anything about what he wants.
He's saying that when the player gets kicked, he wants his message only to be displayed instead of "You were kicked from the game: [MESSAGE]"
like let's say you shutdown your game from the web, if there were people inside it it won't say "You were kicked from the game: The developer has shutdown the game" it'll only display what's after that ("The developer has shutdown the game")
I myself are looking for a similar function, that's how I found this