Remote Event handling multiple scripts

I have a GUI with multiple text buttons.
When clicked, they all do the same thing, but for an individual part.

Obviously, I made a remote event to connect the button to the server, and one button is complete. The issue is, I need 100 of them.

Is there a way I can call the remote event to run a specific script (To apply to the specific part) based on which text button is clicked?
I’m doing this to avoid making 100 different events.
If the way I’m explaining doesn’t make any sense, then I’ll explain more thoroughly of course.

1 Like

have 1 remoteEvent and clone it on button click so your server doesnt have to worry about 100 of them boom

If they’re all doing the same thing to do the part surely you could just send the part as a parameter and run the same code on it.

Agreed with @bytesleuth send the part as a parameter, or send strings that correspond to the part types if they do different things.

1 Like

They all have the same function, but they apply to different parts. Imagine a grid, of text buttons, and a grid of parts. If I clicked button A1, it would apply to part A1

yeah then you should have a serverscript watching all of those since im assuming its just a part in workspace, you dont need a remote event since the gui have their built in functions that a server script can use

What do you mean? Imagine I wanted to have the button A1 when pressed, make part a1 disappear on the server.
That would require the event, no?

is this button a surfacegui or screengui

It’s a Text button on screen gui

do 1 remote event still and have it have a param with the selected part on it like what @bytesleuth and @VisuallyFX said

Easy. In your code that fires the RemoteEvent, you can put a Request string in it, something like

RemoteEvent:FireServer("GetMoney")

and in your server code, you just have a lookup dictionary with all the different requests stored

local Requests = {
   ["GetMoney"] = function()
   end,
}
RemoteEvent.OnServerEvent:Connect(function(Player, Request: string, ...)
   if (Requests[Request]) then
      Requests[Request]()
   end
end)
1 Like

This might actually work. I’ll see later when I get online, thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.