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

How can I detect whether a Remote Event has been fired in a table?

Asked by
Memotag 226 Moderation Voter
5 years ago

I have created a table and ran a loop to grab all of the Remote Events I have created and placed into a folder like this:

local Events = {}

for _, event in pairs(GameEvents:GetChildren()) do
    table.insert(Events, event)
end

Now my question is how would I be able to check if any individual event has been fired in that table? If it is even possible.

1 answer

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago

You'd have to loop through the contents of Events and create an event function for them

for _,v in pairs(Events) do
    v.OnServerEvent:Connect(function()
        --do stuff
    end)
end

But if each even will do something different there's no point in doing this.

doing

local rem=--place

rem.E1.OnServerEvent:Connect(function()
    --do stuff
end)
rem.E2.OnServerEvent:Connect(function()
    --do other stuff
end)

would be fine.

0
Since I plan to have the events do a very similar thing would it be possible to use a module script instead of copy and pasting almost identical code for each functions RemoteEvent? Memotag 226 — 5y
0
@meonlyababy just put the code in the first example I showed you. if there are super small differences in the code you can create an if statement inside the loop and check what v.Name equals to. DanzLua 2879 — 5y
Ad

Answer this question