I was wondering if it was possible to both fire an event and have code prompted by it in the same script. I'm using several coroutines in the same script, and I"m thinking it would be a lot easier to communicate between them if this were possible.
local event = Instance.new("RemoteEvent",game.ReplicatedFirst) coroutine.resume(coroutine.create(function() event.OnServerEvent:connect(function(message) print(message) --prints nil? end) end)) event:FireServer("hello!")
The event does seem to fire here, but it's not returning the value passed to it. Maybe I'm just doing it wrong?
I solved it myself.
local event = Instance.new("RemoteEvent",game.ReplicatedFirst) coroutine.resume(coroutine.create(function() event.OnServerEvent:connect(function(nothing,message) print(message) end) end)) event:FireServer("hello!")
The listener takes the client as the first parameter, and the given parameters as the next ones.
If you know a more efficient method, however, please don't refrain from telling me.