I’ve tried making it through Instance.new() but it almost always stated that it’s either nil, argument or this doesn’t exist, also tried finding any solutions in other posts accross devforum, found only detailed info on Instance.new()
You can use only one remote with an argument saying what function you want to trigger, that’s what I’m doing for my game.
Furthermore, you should be using only one local script/ script that handles every remotes triggers instead of having many, that would be much much easier and more optimized, if that interests you, I can provide you some script of my ongoing game which uses a single remote architecture which is (in my opinion at least) much easier as you don’t need to bother with adding new receivers everytime.
Then, you don’t need all those scripts for this. Use 1 remote event, and 1 local script. The remote event should send the information, so you are not hard coding your labels.
For example, here is my RemotesManager I use for server-side communications:
(don’t mind the token system)
local module = {}
local replicatedStorage = game:GetService("ReplicatedStorage")
local firewall = script.Parent.Firewall
function module.OnServerEvent(player, func_name:string, token, ...)
if func_name then
if require(firewall).checkToken(player, token) then
module.functions[func_name](player, ...)
else
warn("invalid token")
end
end
end
function module.OnServerInvoke(player, func_name:string, token, ...)
if require(firewall).checkToken(player, token) then
return module.functions[func_name](player, ...)
else
warn("invalid token")
end
end
function module:FireClient(player, context:string, ...)
local remote = replicatedStorage.Remotes:FindFirstChildWhichIsA("RemoteEvent", true)
remote:FireClient(player, context, ...)
end
function module:InvokeClient(player, context:string, ...)
local remote = replicatedStorage.Remotes:FindFirstChildWhichIsA("RemoteFunction", true)
remote:InvokeServer(player, context, ...)
end
module.functions = {
ping = function() return true end,
GetData = require(script.Parent.Datastores).returnData,
changeMap = require(script.Parent.Datastores).changeMap,
cutscenePlayed = require(script.Parent.Datastores).saveCutscene,
new_note = require(script.Parent.Notes).newNote,
get_notes = require(script.Parent.Notes).retrieveNotes,
}
return module
and simply a normal script which contains those lines:
Helped me to visualize script & remotes compression.
Yet I was a little confused on module.functions that you’ve made, is it just from yours game or it is required to be in module script?
It’s basically a table with the list of functions,
for example, let’s say you want to fire a remote when a player presses a button, you’ll fire the remote with button_pressed (or any name) and the rest of your arguments, then, in your table you will put button_pressed = your_function.
so whenever the remote is triggered with “button_pressed” argument, it’ll trigger that function with the other arguments.
In conclusion, those names are just for my game, those are the functions triggered from remotes.