why Wont it print everything in server storage when I press G from a local script?
THE LOCAL SCRIPT
local getstuffrem = game.ReplicatedStorage:WaitForChild("RemoteFunction") local play = game.Players.LocalPlayer local uis = game:GetService("UserInputService") uis.InputBegan:Connect(function(input)---,istyping) if input.KeyCode == Enum.KeyCode.G then print("act") --if not istyping then getstuffrem:InvokeServer() end --end end)
AND the SCRIPT
local getstuffrem = game.ReplicatedStorage:WaitForChild("RemoteFunction") getstuffrem.OnServerInvoke:Connect(function(plr) for i,v in pairs(game.ServerStorage:GetChildren()) do print(v.Name) ---------end end end)
OnServerInvoke
is not an event. It will expect a callback function to be assigned to it.
local getstuffrem = game.ReplicatedStorage:WaitForChild("RemoteFunction") getstuffrem.OnServerInvoke = function(plr) for i,v in pairs(game.ServerStorage:GetChildren()) do print(v.Name) end end
Typically you'd use a remote function when you want to return something back. You weren't returning anything back so just use a remote event.