Server Script
local remotefunction = game.ReplicatedStorage.RemoteFunction local ServerStorage = game.ServerStorage remotefunction.OnServerInvoke = function() for i,v in pairs(game.ServerStorage:GetChildren()) do return v.Name -- should return a table end end
Local Script
local remotefunction = game.ReplicatedStorage.RemoteFunction local ValuesGot = remotefunction:InvokeServer() print(ValuesGot)-- Only prints one intvalue print(unpack(ValuesGot)) --Should be a table but it errors saying its a string
The local script should Return the name of the int values which should return the names of 3 intvalues in server storage but its only returning 1
Once a function reaches a return
statement, it stops and returns whatever you said it should return. In this case, the function will only return the name of the first object in the table.
What you should do, is actually return a table of the names.
local names = {} for _, child in ipairs(game:GetService("ServerStorage"):GetChildren()) do table.insert(names, child.Name) end return names
Also, the term for that type of loop is generic for, not "iv loop"