Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with Chatted?

How would I run a string of code in the game if a user chats exactly this,

/m Server Hello!

This is a rough example.

Example

When a player says this \m Server Hello!

It would run this code

workspace.Chat:FireServer("PushChat","[Server]","Hello!")

That code would add a new line to the chat(I already know how to do this) and it would say this in the chat.

Notice how in that chat line it has 3 specific objects

/m -- Runs the Command

Server --The ChatType

Hello! --The Message

Those would correspond to this.

workspace.Chat:FireServer("PushChat","[ChatType]","Message")

1 answer

✓ Accepted answer

Most games like OzzyPig or SmoothBlockModel use a GUI as a chat that uses textlabels, and we both know that you can edit text with everybody as a example

game.Player.PlayerAdded:connect(function(plr)


if plr.Name == "Shedletsky" then
for i,v in pairs (game.Players:GetPlayers()) do
z = Instance.new("TextLabel")
z.Parent = v:WaitForDataReady("ScreenGui").Frame 
z.Text = "[Server]".."Shedlestky has joined the server!"
-- Not full thing like how to get them not to collide just the idea

end

end

end)

This would be way more efficient since doing chat with workspace would not work not that I know of since I check methods that it leads to and also roblox chat is a CoreGui so I don't think doing it with workspace will effect player chat.

game.Players.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(msg)
if  string.sub(msg,1,7):lower() == "\m Server " then

workspace.Chat:FireServer("PushChat","[Server]",string.sub(msg,8))
end

end)
end)




17 comments

0

Wait, that was just an example. I want to force a chat Gui to say this [Server]: Shedletsky has joined the server! I was using that as an example. I want to understand how to define more than one item in a chat line and assign it.

0

Ok i'll write more on it and how to assign it.

0

When a player says this \m Server Hello! It would run this code workspace.Chat:FireServer("PushChat","[Server]","Hello!") That code would add a new line to the chat(I already know how to do this) and it would say this in the chat. [Server]: Hello!

0

Oh, that was a bit unclear i'm also writing while doing this.

0

I have a custom chat by the way.

0

I edited my question.

0

Edited my answer also.

0

Is that what you wanted?

0

Alright, well that would work but not the way I want it to, What if they change the message? How would I make these two variables manipulable? 'ChatType', 'Message'

0

ChatType would be "Server" and Message would be "Hello!"

0

Do you want it to say something else too? Or not because it only work if they chat it exactly.

0

You know in admin command scripts how they can say different things in a command? (something to do with string.sub(1,4) or something..) Like they can do "ChangeStats Intel 500" They can change Intel and 500 to whatever they want to..

0

Updated tell me if it works?

0

Would server be able to be manipulated too?

0

I think so.

0

Yeah it does.

0

Thanks for the help! :)

This discussion is preserved as it was. New answers, comments, and votes are closed.