Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

2 comments

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?

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.