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

Getting model's name from ServerStorage?

So I'm trying to make a basic map selector gui. At the moment I'm only trying to get all the maps' names in ServerStorage which are in a Folder to print. (Everything works in play-solo in-studio, but not online or in test server) I have a local script in a gui which fires a remote event in a server script located in the ServerScriptService.

This is what I have in the server script:

local replicatedStorage = game:GetService("ReplicatedStorage")
local networking = replicatedStorage:WaitForChild("networking")
local remoteFunctions = networking:WaitForChild("remoteFunctions")
local remoteEvents = networking:WaitForChild("remoteEvents")
local remote = remoteEvents:WaitForChild("remote")
local remote2 = remoteEvents:WaitForChild("makeTrainerGuiVisible")
local remote3 = remoteEvents:WaitForChild("getMaps")
local serverStorage = game:GetService("ServerStorage")
local mapFolder = serverStorage:WaitForChild("mapFolder")

remote3.OnServerEvent:connect(function(plr)
	local player = plr
	local mapList = {}
	local mapTable = mapFolder:GetChildren()
	for i = 1, #mapTable  do
		table.insert(mapList, mapTable[i])
	end
	print (mapList[1])
	
	remote3:FireClient(player, mapList)
end)

The server script successfully prints the name of the maps, but the local script doesn't print anything. Why would that be, what can I do to fix this?

Here's what's in the local script:

remote3.OnClientEvent:connect(function(mapList)
	for i, v in pairs(mapList) do
		print(i..'-'..tostring(v))
	end
end)

1 answer

✓ Accepted answer

Nothing in ServerStorage can be accessed by the client. None of it exists on the client, it is never replicated. You can't find it. If you put it in ReplicatedStorage, however, then it does replicate and the client is able to access it.

I don't know why you're trying to pass server-sided objects to the client, but you can send a table with just the names of all of the maps instead.

1 comment

0

Ah.. crap, of course... Many thanks!

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