Revelted
|
  |
| Joined: 02 Nov 2014 |
| Total Posts: 503 |
|
|
| 19 Jan 2017 06:25 PM |
So , I made a function, but I want to be able to chat something to call it.
I don't know how to connect chatting to the function, and I also want it so that it's only me that can say it and connect it?
If this makes sense let me know |
|
|
| Report Abuse |
|
|
Revelted
|
  |
| Joined: 02 Nov 2014 |
| Total Posts: 503 |
|
|
| 19 Jan 2017 06:26 PM |
| I guess kinda like an admin command, but for me only |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 06:27 PM |
basically player.Chatted(msg)
|
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 06:29 PM |
| Use Chatted and check if the player name that chatted is equal to yours. Then run it |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 06:30 PM |
Use the example for setting only for a player
http://wiki.roblox.com/index.php?title=API:Class/Player/Chatted |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 06:37 PM |
I made it a little fancier with support for arguments since you didn't specify whether or not you wanted that. It just takes the part of the message after the command string and uses that as the arguments to your function.
game.Players.PlayerAdded:connect(function(player) if player.Name == "Revelted" then player.Chatted:connect(function(message) local command = "!myfunction " -- Change command string by changing this. if message:lower():sub(1,command:len()) == command:lower() then MyFunction(message:sub(command:len()+1, -1)) -- Args for command. end end) end end |
|
|
| Report Abuse |
|
|
Revelted
|
  |
| Joined: 02 Nov 2014 |
| Total Posts: 503 |
|
|
| 19 Jan 2017 06:40 PM |
| Im a newbie scripter, so i wanna stick with something basic q.q |
|
|
| Report Abuse |
|
|
Revelted
|
  |
| Joined: 02 Nov 2014 |
| Total Posts: 503 |
|
|
| 19 Jan 2017 06:42 PM |
@Tardis
How does that connect to my function? |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 06:44 PM |
It's not as scary as it looks and I really recommend breaking it down, but here's a barebones version that doesn't take arguments and the command has to literally match your message (case sensitive and stuff):
game.Players.PlayerAdded:connect(function(player) if player.Name == "Revelted" then player.Chatted:connect(function(message) if message == "!myfunction" then MyFunction() end end) end end |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2017 06:45 PM |
@Rev
It connects to your function where it calls MyFunction(). |
|
|
| Report Abuse |
|
|
Revelted
|
  |
| Joined: 02 Nov 2014 |
| Total Posts: 503 |
|
| |
|
Revelted
|
  |
| Joined: 02 Nov 2014 |
| Total Posts: 503 |
|
|
| 19 Jan 2017 06:48 PM |
So I have this
game.Players.PlayerAdded:connect(function(player) if player.Name == "Player1" then player.Chatted:connect(function(message) if message == "huh" then SpawningFire() end end) end end)
but when I say huh in testing mode, it doesnt work, nor does it give an error |
|
|
| Report Abuse |
|
|
Revelted
|
  |
| Joined: 02 Nov 2014 |
| Total Posts: 503 |
|
|
| 19 Jan 2017 06:50 PM |
| nvm i put it at the bottom of my script when it needs to be at the top |
|
|
| Report Abuse |
|
|