Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to make a custom kick message?

Asked by 4 years ago
Edited 4 years ago

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

0
i don't think it's possible User#23252 26 — 4y
0
it is as i have seen games do `You have been banned!` as a kick message in a few videos by youtubers EnzoTDZ_YT 275 — 4y
0
As of research that I've done, it's not really that possible unless you create your own kick function. To do this you could use a module and create everything in there. But, not possible to do with ROBLOX kicks. https://devforum.roblox.com/t/custom-kick-screens/309293 killerbrenden 1537 — 4y
0
Thanks EnzoTDZ_YT 275 — 4y
0
But this didn’t work as it says he couldn’t make one EnzoTDZ_YT 275 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
he doesn't want the "You have been kicked from this game" to prefix the kick message User#23252 26 — 4y
0
you understood him completely wrong Firopense 0 — 3y
0
and his function /stop will stop the whole server meaning that the m:sub(7) is the reason NOT the p l a y e r ' s name Firopense 0 — 3y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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

0
I have a custom chat so that wouldn’t of worked but I don’t want the You have been kicked in it as I have seen many games do something like you have been banned and that is what I am trying to achieve and I want it says Server has shutdown instead EnzoTDZ_YT 275 — 4y
Log in to vote
0
Answered by 3 years ago

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

0
I just decided to code with unity and was able to do this by sending an alert that the server was shutdown i know this isnt what you want but just saying this is what i am doing now EnzoTDZ_YT 275 — 3y

Answer this question