I’m attempting to send a folder located in serverstorage from the server to a client via a remote event.
Here are parts of the script:
--In the server
local Folder = game.ServerStorage.Folder
Event:FireAllClients("M", Folder)
--In the client
Event.OnClientEvent:Connect(function(event, folder)
print(folder) -- it is nil
end)
I’m figuring that it’s because I can’t access it from the client since it’s part of the server, but I’m not entirely sure if that’s the case.
Oh nevermind, I believe it’s because, when firing to clients the first variable has to be a player value.
--In the server
local Folder = game.ServerStorage.Folder
Event:FireAllClients(plr,"M", "Folder")
--In the client
Event.OnServerEvent:Connect(function(event, folder)
print(folder) -- it is nil
end)
You can’t access the ServerStorage in a LocalScript, it’s replicated across the server side
Put it in ReplicatedStorage instead:
--In the server
local Folder = game.ReplicatedStorage.Folder
Event:FireAllClients("M", Folder)
--In the client
Event.OnClientEvent:Connect(function(event, folder)
print(event)
print(folder)
end)
thats what i did as the fix but i think i might do what @0xzemqkaixlqpolwmzvn had said and put them into a table to keep it “encrypted” but im feeling pretty lazy rn so