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.
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
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)