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

Help with Chatted?

Asked by 10 years ago

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.

[Server]: Hello!

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

Log in to vote
2
Answered by
HexC3D 830 Moderation Voter
10 years ago

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)




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. IntellectualBeing 430 — 10y
0
Ok i'll write more on it and how to assign it. HexC3D 830 — 10y
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! IntellectualBeing 430 — 10y
0
Oh, that was a bit unclear i'm also writing while doing this. HexC3D 830 — 10y
View all comments (13 more)
0
I have a custom chat by the way. IntellectualBeing 430 — 10y
0
I edited my question. IntellectualBeing 430 — 10y
0
Edited my answer also. HexC3D 830 — 10y
0
Is that what you wanted? HexC3D 830 — 10y
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' IntellectualBeing 430 — 10y
0
ChatType would be "Server" and Message would be "Hello!" IntellectualBeing 430 — 10y
0
Do you want it to say something else too? Or not because it only work if they chat it exactly. HexC3D 830 — 10y
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.. IntellectualBeing 430 — 10y
0
Updated tell me if it works? HexC3D 830 — 10y
0
Would server be able to be manipulated too? IntellectualBeing 430 — 10y
0
I think so. HexC3D 830 — 10y
0
Yeah it does. HexC3D 830 — 10y
0
Thanks for the help! :) IntellectualBeing 430 — 10y
Ad

Answer this question