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

Need help with remote functions: Not printing everything is server storage??????"

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)

1 answer

✓ Accepted answer

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.

1 comment

0

hmm ok thank you

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