#Message Scrambler

193 messages · Page 1 of 1 (latest)

mental quartz
#

Hello, I would like to create a message scrambler.

The use of this is to encrypt messages sent by an user. Only specified people should be able to see the encrypted message as original one.

Example:
Person A is on team red and says: "Hello."
Person B is on team blue and only sees something like: "H%a2*"

Code:

I already created this code:
If I go to a local test server and try it out, it sends the scrambled message into the Server Output in Roblox Studio. But the problem is that the message that is send to the chat isn't scrambled.

#
local function shuffleString(str)
    local shuffled = {}
    for i = 1, #str do
        local char = str:sub(i, i)
        if char ~= " " then -- Leave space as it is
            table.insert(shuffled, char)
        end
    end
    for i = #shuffled, 2, -1 do
        local j = math.random(i)
        shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
    end
    return table.concat(shuffled)
end

-- Function to scramble the message
local function scrambleMessage(playerName, message)
    local scrambledMessage = ""
    for i = 1, #message do
        local char = message:sub(i, i)
        if char == " " then
            scrambledMessage = scrambledMessage .. " " -- Leave the space as it is
        else
            scrambledMessage = scrambledMessage .. string.char(math.random(32, 126)) -- Random ASCII-Symbol
        end
    end
    return playerName .. ": " .. scrambledMessage -- Encrypt player name and return

-- Event-Handler for receiving the message
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if string.sub(message, 1, 9) == "/scramble" then -- If "/scramble" at the beginning of the message
            local scrambledMessage = scrambleMessage(player.Name, message) -- Encrypt message
            for _, recipient in ipairs(game.Players:GetPlayers()) do
                message = scrambleMessage(player.Name,message)
                print(scrambledMessage) -- Send encrypted message to console
            end
        end
        print(message)
        
    end)
    
    
end)
nocturne flicker
#
-- Function to scramble the letters in a string
local function shuffleString(str)
    local shuffled = {}
    for i = 1, #str do
        local char = str:sub(i, i)
        if char ~= " " then -- Leave space as it is
            table.insert(shuffled, char)
        end
    end
    for i = #shuffled, 2, -1 do
        local j = math.random(i)
        shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
    end
    return table.concat(shuffled)
end

-- Function to scramble the message
local function scrambleMessage(playerName, message)
    local scrambledMessage = ""
    for i = 1, #message do
        local char = message:sub(i, i)
        if char == " " then
            scrambledMessage = scrambledMessage .. " " -- Leave the space as it is
        else
            scrambledMessage = scrambledMessage .. string.char(math.random(32, 126)) -- Random ASCII-Symbol
        end
    end
    return playerName .. ": " .. scrambledMessage -- Encrypt player name and return
end

-- Event-Handler for receiving the message
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if string.sub(message, 1, 9) == "/scramble" then -- If "/scramble" at the beginning of the message
            local scrambledMessage = scrambleMessage(player.Name, message) -- Encrypt message
            for _, recipient in ipairs(game.Players:GetPlayers()) do
                message = scrambleMessage(player.Name,message)
                print(scrambledMessage) -- Send encrypted message to console
                
                recipient.StarterGui:SetCore("ChatMakeSystemMessage", {Text = scrambledMessage} )

            end
        end

        print(message)
        
    end)

end)

try this code i just added one line inside the for _, recipient loop

mental quartz
nocturne flicker
#

sorry @mental quartz try again i missed an "}"

lunar notchBOT
#

studio** You are now Level 4! **studio

mental quartz
nocturne flicker
#
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if string.sub(message, 1, 9) == "/scramble" then -- If "/scramble" at the beginning of the message
            local scrambledMessage = scrambleMessage(player.Name, message) -- Encrypt message
            for _, recipient in ipairs(game.Players:GetPlayers()) do
                message = scrambleMessage(player.Name,message)
                print(scrambledMessage) -- Send encrypted message to console
                
                recipient.StarterGui:SetCore("ChatMakeSystemMessage", {Text = scrambledMessage} )

            end
        end
        print(message)
        
    end)
    
    
end)
#

sorry made some mistakes this should work now

#
-- Function to scramble the letters in a string
local function shuffleString(str)
    local shuffled = {}
    for i = 1, #str do
        local char = str:sub(i, i)
        if char ~= " " then -- Leave space as it is
            table.insert(shuffled, char)
        end
    end
    for i = #shuffled, 2, -1 do
        local j = math.random(i)
        shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
    end
    return table.concat(shuffled)
end

-- Function to scramble the message
local function scrambleMessage(playerName, message)
    local scrambledMessage = ""
    for i = 1, #message do
        local char = message:sub(i, i)
        if char == " " then
            scrambledMessage = scrambledMessage .. " " -- Leave the space as it is
        else
            scrambledMessage = scrambledMessage .. string.char(math.random(32, 126)) -- Random ASCII-Symbol
        end
    end
    return playerName .. ": " .. scrambledMessage -- Encrypt player name and return
end

-- Event-Handler for receiving the message
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if string.sub(message, 1, 9) == "/scramble" then -- If "/scramble" at the beginning of the message
            local scrambledMessage = scrambleMessage(player.Name, message) -- Encrypt message
            for _, recipient in ipairs(game.Players:GetPlayers()) do
                message = scrambleMessage(player.Name,message)
                print(scrambledMessage) -- Send encrypted message to console
                
                recipient.PlayerGui:SetCore("ChatMakeSystemMessage", {Text = scrambledMessage} )

            end
        end

        print(message)
        
    end)

end)

@mental quartz try this

mental quartz
#

Alright I will try

mental quartz
lunar notchBOT
#

studio** You are now Level 1! **studio

nocturne flicker
#

sry had to be PlayerGui fixed it copy paste again

jagged scaffold
nocturne flicker
#

sure looked at your code already

#

trying something

jagged scaffold
#

thank you, ill be in that thread

#

sorry to intrude Nic, good luck with your script!

mental quartz
mental quartz
#

np

nocturne flicker
#

Sorry mistyped

#

excuse my dumbass didn't see that

#

copy paste again and everything should work now

mental quartz
nocturne flicker
#
-- Function to scramble the letters in a string
local function shuffleString(str)
    local shuffled = {}
    for i = 1, #str do
        local char = str:sub(i, i)
        if char ~= " " then -- Leave space as it is
            table.insert(shuffled, char)
        end
    end
    for i = #shuffled, 2, -1 do
        local j = math.random(i)
        shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
    end
    return table.concat(shuffled)
end

-- Function to scramble the message
local function scrambleMessage(playerName, message)
    local scrambledMessage = ""
    for i = 1, #message do
        local char = message:sub(i, i)
        if char == " " then
            scrambledMessage = scrambledMessage .. " " -- Leave the space as it is
        else
            scrambledMessage = scrambledMessage .. string.char(math.random(32, 126)) -- Random ASCII-Symbol
        end
    end
    return playerName .. ": " .. scrambledMessage -- Encrypt player name and return
end

-- Event-Handler for receiving the message
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if string.sub(message, 1, 9) == "/scramble" then -- If "/scramble" at the beginning of the message
            local scrambledMessage = scrambleMessage(player.Name, message) -- Encrypt message
            for _, recipient in ipairs(game.Players:GetPlayers()) do
                message = scrambleMessage(player.Name,message)
                print(scrambledMessage) -- Send encrypted message to console
                
                recipient:Chat(scrambledMessage)

            end
        end

        print(message)
        
    end)

end)

try this now - this is the only thing i can currently think of

mental quartz
#

ôk

nocturne flicker
#

Alr i just figured you cannot directly send messages to the player through the chat in a Server Script

You need to use a Local Script
you can create a remoteEvent that Fires to All Clients with the scrambled Message and then put it in chat

#

local scrambleEvent = game:GetService("ReplicatedStorage").scrambleEvent

-- Function to scramble the letters in a string
local function shuffleString(str)
    local shuffled = {}
    for i = 1, #str do
        local char = str:sub(i, i)
        if char ~= " " then -- Leave space as it is
            table.insert(shuffled, char)
        end
    end
    for i = #shuffled, 2, -1 do
        local j = math.random(i)
        shuffled[i], shuffled[j] = shuffled[j], shuffled[i]
    end
    return table.concat(shuffled)
end

-- Function to scramble the message
local function scrambleMessage(playerName, message)
    local scrambledMessage = ""
    for i = 1, #message do
        local char = message:sub(i, i)
        if char == " " then
            scrambledMessage = scrambledMessage .. " " -- Leave the space as it is
        else
            scrambledMessage = scrambledMessage .. string.char(math.random(32, 126)) -- Random ASCII-Symbol
        end
    end
    return playerName .. ": " .. scrambledMessage -- Encrypt player name and return
end

-- Event-Handler for receiving the message
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if string.sub(message, 1, 9) == "/scramble" then -- If "/scramble" at the beginning of the message
            local scrambledMessage = scrambleMessage(player.Name, message) -- Encrypt message
            scrambleEvent:FireAllClients(scrambledMessage)
            message = scrambleMessage(player.Name,message)
              
            print(scrambledMessage)
  
        end

        print(message)
        
    end)

end)

inside the local script (this local script needs to be inside: StarterPlayer > StarterPlayerScripts

local scrambleEvent = game:GetService("ReplicatedStorage").scrambleEvent
scrambleEvent.OnClientEvent:Connect(function(scrambledMessage)
  game:GetService("StarterGui"):SetCore("ChatMakeSystemMessage", {Text = scrambledMessage})
end
#

now just create a remote event inside replicated storage called "scrambleEvent" and it should work fine @mental quartz

mental quartz
#

So the first big script needs to be put in here? @nocturne flicker

nocturne flicker
#

no the small script

#

and make it a "Local Script"

mental quartz
nocturne flicker
#

yes

mental quartz
nocturne flicker
#

nope normal

lunar notchBOT
#

studio** You are now Level 2! **studio

mental quartz
#

The ChatRemoteEvent?

#

23:11:06.279 Players.Player2.PlayerScripts.LocalScript:4: Expected ')' (to close '(' at line 2), got <eof> - Studio - LocalScript:4

nocturne flicker
#

just leave it there for now

mental quartz
#

Was send to the Player Testin window.

mental quartz
mental quartz
#

But the text hasn't been scrambled either in the normal output:

nocturne flicker
#

but in the normal chat just not the chat bubble?

mental quartz
#

did these three things

nocturne flicker
#

perfect

#

but in the normal chat is the word scrambled?

mental quartz
#

Uh?

#

There is no chat.

nocturne flicker
#

it hasn`t alr

#

local scrambleEvent = game:GetService("ReplicatedStorage").scrambleEvent
scrambleEvent.OnClientEvent:Connect(function(scrambledMessage)

-- in here the new code for the chat

end)

#

U'm running of ideas maybe with this it will work

lunar notchBOT
#

studio** You are now Level 5! **studio

mental quartz
#

I am not sure why it says at 51 because it only has 4 lines.

nocturne flicker
#

alr i'm currently thinking - this is the new chat - in the old on it worked just fine

#

sorry for this confusion i will get back to you with a solutin

#

If i May Forwarded you to this:
https://youtu.be/LFModLTHcqE?si=pG62YzD0P9TW-et4

In this video, I will be teaching all of you how to create SYSTEM MESSAGES with the new TextChatService in Roblox Studio!

Join this channel to get special access to perks!:
https://www.youtube.com/channel/UCLYXLqQ5Fd_TVQvkOIhsEcg/join

Local Script, Starter Gui:

local message = ""
game.TextChatService.TextChannels.RBXGeneral:DisplaySystemMes...

▶ Play video
mental quartz
mental quartz
mental quartz
# nocturne flicker If i May Forwarded you to this: https://youtu.be/LFModLTHcqE?si=pG62YzD0P9TW-et4

Si, I am not sure what exactly I did but I put this in a local script in StarterGUI because the person in the video did the same. I got this as an **output **" 10:58:27.258 TexctChabbeks is not a valid member of TextChatService "TextChatService" - Client - LocalScript:6" Script: local message = _G.message --print(_G.message) --local scrambleEvent = game:GetService("ReplicatedStorage").scrambleEvent --scrambleEvent.OnClientEvent:Connect(function(scrambledMessage) -- game.StarterGui:SetCore("ChatMakeSystemMessage", {Text = scrambledMessage, Color = Color3.fromRGB(255, 0, 0), font = Enum.Font.GothamMedium)} game.TextChatService.TexctChabbeks.RBXGeneral:DisplaySystemMessage(_G.message)

#

In addition, I did this in the ServerScriptService script:

#

(changed the message = scrambleMessage... to _G.message = scrambleMessage...)

nocturne flicker
#

It is. .TextChannel

mental quartz
#

Thank you, will try it out.

mental quartz
mental quartz
nocturne flicker
#

And the player?

#

Don't you have to put him in aswell? Inside the calling

mental quartz
#

Uh.

lunar notchBOT
#

studio** You are now Level 3! **studio

mental quartz
#

If you tell so then I probably need.

mental quartz
nocturne flicker
#

Is _G.Message - does this print something

#

Cause if it doesn't then it will be nil

#

Try printing it

mental quartz
nocturne flicker
#

Does it print something

mental quartz
#

Wait I will try.

mental quartz
nocturne flicker
#

Just what I thought

#

Make the remote Event work again - and then just assign it to a variable

#

Then it'll work

nocturne flicker
#

Yeah

#

Just make the script again

mental quartz
mental quartz
mental quartz
#

So this is how it looks currently. Now I need to disable the LocalScript from StarterGui and create a new LocalScript with the old script you just send?

nocturne flicker
#

Just paste it in the same script / overwrite the old code

#

No need for disabling or creating a new script

mental quartz
#

Ok.

nocturne flicker
#

Yeah

mental quartz
#

ok I will try

nocturne flicker
#

But instead of gmessage put

#

scrambledMessage there

mental quartz
#

Ok

mental quartz
#

That is what I got.

#

So like two players on two different teams. No error log, but the player on the other team is able to see the normal message.

nocturne flicker
#

Can you invite me to the place

mental quartz
nocturne flicker
#

no

mental quartz
#

Alright.

nocturne flicker
#

so you first add me on roblox as a friend

mental quartz
#

Alright you should be addeed.

nocturne flicker
#

test it now please

#

i change the bubble chat in a secound

mental quartz
#

uh wait

mental quartz
#

Can we also go into the same test thing a look if we can see the message of each other or not?

#

(If this is possible)

nocturne flicker
#

sure

mental quartz
#

How does it work?

lunar notchBOT
#

studio** You are now Level 4! **studio

nocturne flicker
#

teamtest

mental quartz
#

Ok

nocturne flicker
mental quartz
nocturne flicker
mental quartz
#

Hmm well it shows the in game thing now the name needs to be removed and somehow the old message too (for players of another team). For the players of my team it needs to be visible in normal text.

nocturne flicker
#

i made it DisplayName

#

so it now shows the name you see in the leaderboard

mental quartz
#

But is it possible to remove the "/scramble Hello" for me so I only see your scrambledMessage?

#

Since I am on team red.

#

And you team yellow.

nocturne flicker
#

try now

mental quartz
#

Oh it has a nice command thing now.

#

Wow.

mental quartz
#

Can you also hop in game?

nocturne flicker
#

everything works now

#

hop in teamtest @mental quartz

mental quartz
#

Alright

#

Arox. I am sorry but I need to go offline since it is late for me. I would test it tomorrow if you get the details to work. As of for now I already want to thank you for the time and effort you spend right now to make the scripts work. It is really kind of you. Thank you 😃

#

I really didn’t expected someone to do so much for me when I opened this thread.

nocturne flicker
#

try again

#

now it should work (like 1 sec

mental quartz
nocturne flicker
#

mhhh

lunar notchBOT
#

studio** You are now Level 6! **studio

nocturne flicker
#

the team sees the original message while all the others will not

#

the bubblechat however will stay scrambled for everyone

mental quartz
mental quartz
nocturne flicker
#

sure

#

bubblechat is disabled now

#

everything works now

mental quartz
#

Nice. And one last question (I hope): Is it also easy to make it so if I write „/scramble“ enter, [text] enter; the. The text will be also scrambled eventhough it is sent in a new message. So like you can enable the feature and it will write all of your messages scrambled and if you type „/scramble“ again, the scrambled messages will be unscrambled again. Your teammates messages however can you see at all time, regardless if you have scramble activated yourself or not.

#

Is this described understandable?

nocturne flicker
#

i could

mental quartz
nocturne flicker
#

yellow team on the right red on the left

#

yello can see messages red not

#

and vice versa

mental quartz
#

Alright and what is vice versa?

#

Seems like Latin

nocturne flicker
#

and also for the others aswell

mental quartz
#

Oh now I get it I think

#

This is so cool

#

Thank you Arox!

nocturne flicker
#

sorry

#

so you have to type /scramble Every time

#

but i have a question - why don't you use teamchat @mental quartz

mental quartz
mental quartz
# nocturne flicker but i have a question - why don't you use teamchat <@706885961170157598>

Well with the scrambler it is like you see other people talking but could be curious about what they are talking. You just see characters and don’t know what it is about what they are talking. With team chat you can’t see interaction at all. If you are in a game where you want to to thing like in roleplay, it is cooler/nicer/better to have such a scrambler. This also makes the team which is using it more elite depending on context.

nocturne flicker
#

True

mental quartz
#

@nocturne flicker I just tested the scrambled you scripted yesterday and it works really good. Now I tried something new: I know you said it won't work with that I only need to type /scramble and I tried something. Now if I do /scramble every message after gets scrambled until I write /soff. But there is a small issue as you already described. The message for my own team gets send twice. The message for the other team is also twice (once scrambled the other once unscrambled) - (see Screenshots). Would it work like the code is right now (I can either send it jhere or you look in the studio) or would it still not work as you described? (Is it possible to make this as it should be?)

mental quartz
#

@nocturne flicker .

nocturne flicker
#

It would still not work since the messages won’t get blocked

mental quartz