Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
Tizzel40 243 Moderation Voter
5 years ago

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

Log in to vote
0
Answered by 5 years ago

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.

0
hmm ok thank you Tizzel40 243 — 5y
Ad

Answer this question