why Wont it print everything in server storage when I press G from a local script?
THE LOCAL SCRIPT
01 | local getstuffrem = game.ReplicatedStorage:WaitForChild( "RemoteFunction" ) |
02 |
03 |
04 | local play = game.Players.LocalPlayer |
05 |
06 | local uis = game:GetService( "UserInputService" ) |
07 |
08 |
09 | uis.InputBegan:Connect( function (input) ---,istyping) |
10 |
11 |
12 | if input.KeyCode = = Enum.KeyCode.G then |
13 | print ( "act" ) |
14 | --if not istyping then |
15 |
AND the SCRIPT
01 | local getstuffrem = game.ReplicatedStorage:WaitForChild( "RemoteFunction" ) |
02 |
03 |
04 |
05 |
06 |
07 |
08 | getstuffrem.OnServerInvoke:Connect( function (plr) |
09 |
10 | for i,v in pairs (game.ServerStorage:GetChildren()) do |
11 | print (v.Name) |
12 | ---------end |
13 | end |
14 | end ) |
OnServerInvoke
is not an event. It will expect a callback function to be assigned to it.
1 | local getstuffrem = game.ReplicatedStorage:WaitForChild( "RemoteFunction" ) |
2 |
3 | getstuffrem.OnServerInvoke = function (plr) |
4 | for i,v in pairs (game.ServerStorage:GetChildren()) do |
5 | print (v.Name) |
6 |
7 | end |
8 | 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.