sm1t3
|
  |
| Joined: 04 Jun 2011 |
| Total Posts: 103 |
|
|
| 23 Jun 2015 07:26 PM |
Okay I tried making a command where when you say "meteor", a meteor appears with a message. But for some reason, when i go into test mode and type meteor, nothing happens. Can someone help me resolve this problem, I think something is wrong with the script.
function processCommand(speaker, message) if message == "meteor" then local m = Instance.new("Message") m.Parent = game.Workspace m.Text = "A meteor is coming towards us!!! AHHH!!!" wait(3) m:remove() local b = Instance.new("Part") b.Parent = game.Workspace b.Position = Vector3.new(0,5000,0) b.Size = Vector3.new(200,500,200) b.BrickColor = BrickColor.new(199) b.Transparency = 0 wait(10) b:remove() wait(1000) end end
|
|
|
| Report Abuse |
|
|
sm1t3
|
  |
| Joined: 04 Jun 2011 |
| Total Posts: 103 |
|
| |
|
|
| 23 Jun 2015 07:39 PM |
| do you even have anything calling the function |
|
|
| Report Abuse |
|
|
sm1t3
|
  |
| Joined: 04 Jun 2011 |
| Total Posts: 103 |
|
|
| 23 Jun 2015 07:42 PM |
| You dont need to, I dont think so cause Its a function thats activated once you speak. @Lucas1270z |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2015 07:47 PM |
Uh, no its not. Theres no such thing as a function that is automatically called in Roblox Lua.
You still have to connect it to a chat event. Add this to the bottom of the script:
function registerPlayer(player) player.Chatted:connect(function (msg) processCommand(player,msg) end) end
for _,p in pairs(game.Players:GetPlayers()) do registerPlayer(p) end
game.Players.PlayerAdded:connect(registerPlayer) |
|
|
| Report Abuse |
|
|
sm1t3
|
  |
| Joined: 04 Jun 2011 |
| Total Posts: 103 |
|
|
| 23 Jun 2015 07:52 PM |
New script: function processCommand(speaker, message) if message == "meteor" then local m = Instance.new("Message") m.Parent = game.Workspace m.Text = "A meteor is coming towards us!!! AHHH!!!" wait(3) m:remove() local b = Instance.new("Part") b.Parent = game.Workspace b.Position = Vector3.new(0,5000,0) b.Size = Vector3.new(200,500,200) b.BrickColor = BrickColor.new(199) b.Transparency = 0 wait(10) b:remove() wait(1000) end end
function registerPlayer(player) player.Chatted:connect(function (msg) processCommand(player,msg) end) end
for _,p in pairs(game.Players:GetPlayers()) do registerPlayer(p) end
game.Players.PlayerAdded:connect(registerPlayer)
Thank you so much for fixing it. Bless your soul xD Im still a beginner scripter so I couldnt figure it out. |
|
|
| Report Abuse |
|
|