Remote functions

Remote function isnt working, no errors. It completely freezes my client script also

-- client

local plr = game.Players.LocalPlayer
if plr.Name == "Max_1299" or plr.Name == "TheStrongest3845" then
	wait(5)
	print("!") -- this runs
	local returnValue = game.ReplicatedStorage.DevClient:Invoke() -- this says nothing in output
	print("!x2") -- this doesnt run, neither do any more lines
	
	for i,v in pairs(returnValue) do
		local t= script.TextButton:Clone()
		t.Name = v.Name
		t.Parent = script.Parent.ScrollingFrame
		t.Text = v.Name
		t.MouseButton1Up:Connect(function()
			game.ReplicatedStorage.Dev:FireServer("spawn",v.Name)
		end)
	end
end

-- Server

game.ReplicatedStorage.DevClient.OnInvoke = function(plr)
	print("hi") -- this doesnt run
	local t = {}

	for i,v in pairs(game.ServerStorage.Mobs:GetChildren()) do
		print(v)
		table.insert(t,v)
	end

	return t
end

You’re using a BindableFunction instead of a RemoteFunction. A BindableFunction is from client to client OR server to server, and cannot go from client to server or vice versa. A RemoteFunction is for client to server (or server to client).

Your script is yielding because there is no listener for the DevClient BindableFunction on the client, so it will hang forever.

Your code should look something like:

--client
local returnValue = game.ReplicatedStorage.DevClient:InvokeServer()
--server
game.ReplicatedStorage.DevClient.OnServerInvoke = function(player)

end

Thanks, just to check (as i cant right now) can i do
return game.ServerStorage.Mobs:GetChildren() instead of what i was doing before on the server with tables

Objects in ServerStorage exist entirely on the Server, so the Client will have no idea that they exist. If you try to pass references of these objects to the client, it wont work. If you need the client to reference these objects, either put them in ReplicatedStorage (in which case you can reference these directly from the client without needing to invoke the server), or create clones of the objects and put them somewhere the client can recognize them (ReplicatedStorage or Workspace) and pass the clones to the client.