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

How do you make a onChatted script, like admin commands? [closed]

Asked by 10 years ago

I have tried to make a onChatted script however, I keep on failing. Please help me.

Closed as Not Constructive by evaera

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

3 answers

Log in to vote
1
Answered by
war8989 35
10 years ago

Hi XMessi10,

I understand, I also had difficulty understanding how to do onChatted scripts before, so I made a simple onChatted script for you. Here ya are:

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if(msg == "") then
            -- do something
        end
    end)
end)

Hope this helps! - war8989

0
The script example I gave is meant to check if a player says something, so if you would like to test it, add something in between the quotation marks and replace the comment with whatever you want. war8989 35 — 10y
0
Thanks I'll try it out. XMessi10 0 — 10y
Ad
Log in to vote
0
Answered by
Asleum 135
10 years ago

Use the player.Chatted event. For example :

game.Players.Player.Chatted:connect(function(Message)
print("game.Players.Player has said : "..Message)
end)

If you're looking for some more example codes, the wiki has a whole article about chat commands : http://wiki.roblox.com/index.php?title=Chat_commands

Log in to vote
0
Answered by
Maxomega3 106
10 years ago

I noticed that the tag was "LocalScripts", and these scripts must be global if you use .PlayerAdded (Pretty sure)