So the player is meant to give a response in a certain amount of time; but for some reason this isnt quite working the way Id expect it to.
"Chat" = nil
It waits for my response and everything (unless timeout) but Chat always comes up a nil. Help?
I understand its returning to fast but, how can I slow that down to get the correct chatted response?
function JARVIS:WaitForReply(Player) local Con local Chat = "" delay(12,function() Con:disconnect() end) Con = Player.Chatted:connect(function(Message) Chat = Message --> Message is fine end) Player.Chatted:wait() Con:disconnect() print(Chat) --> nil value return Chat end
Right.. So I figured it out myself. I just wasnt very with it at that current time. I made a stupid mistake. (Actually multiple)
For anyone wanting the answer to this its below. :)
function JARVIS:WaitForReply(Player) local Con,Chat delay(12,function() Con:Disconnect() return nil end) Con = Player.Chatted:connect(function(Message) Chat = Message end) Player.Chatted:wait() wait() Con:Disconnect() return Chat end
You shouldn’t put events in functions:
loca chat = '' local connection = player.Chatted:Connect(function(msg) chat = msg print(chat) connection:Disconnect() end)