Remote Function Not Returning

This is a problem I have been having for about 4 days now. My mind is completely blank as to why it doesn’t work.

It just…doesn’t carry on.

Basically I am sending a RemoteFunction to the server so that I can spawn as a Character.

The Character spawns however the camera stays where it is because the LocalScript doesn’t detect that the Remote Function returned something. Any Ideas why?

Code:

LocalScript
-- References
local InfractionModule = require(script.InfractionController)
local LoadCharacter = ReplicatedStorage.Remotes.LoadCharacter
print(script.ClassName,"running:",script.Name) -- Prints

local Characters = LoadCharacter:InvokeServer("MarkOneDroid")
print("Agents loaded. Mobilizing unit.") -- Does not print WHY WHY WHY
local Leader = InfractionModule:Mobilize(Characters)
print("Agents mobilized and organized.") -- Does not print

ServerScript
LoadCharacter.OnServerInvoke = function(Player,CharacterRequest)
	print(Player,"requested ",CharacterRequest) -- prints correctly
	if CharacterRequest == "MarkOneDroid" then
		print("Loading agent.") -- prints
		local Agents = InfractionModule:LoadSquad(Player,workspace.InfractionSpawn.AgentSpawner.Union.Position)
		print(Agents,"loaded...") -- prints correctly
		return Agents
	end
end
ServerModuleScript
-- Global Functions
function InfractionHandler:LoadSquad(Player, SpawnLocation)
	print("Loading squad: Sedecim Mark One Agents at location",SpawnLocation)
	local Sedecim = Instance.new("Model")
	Sedecim.Parent = workspace
	Sedecim.Name = Player.Name
	for i = 1, MAX_UNITS do
		local Agent = MARK_ONE_AGENT:Clone()
		Agent.Parent = Sedecim
		Agent:SetPrimaryPartCFrame(CFrame.new(SpawnLocation))
	end
	Player.Character = Sedecim

	for _, BasePart in ipairs(Sedecim:GetDescendants()) do
		if BasePart:IsA("BasePart") then
			BasePart:SetNetworkOwner(Player)
		end
	end
	table.insert(InfractionHandler.Players,{Player,Sedecim:FindFirstChildOfClass("Model"),SpawnLocation})
	print("Sedecim",Sedecim,"loaded. Returning") -- prints
	return Sedecim
end
Output
 11:40:30.282  LocalScript running: SpawnScript  -  Client - SpawnScript:1
 11:40:30.285  ModuleScript running: InfractionController  -  Client - InfractionController:1
 11:40:30.285  LocalScript running: SpawnScript  -  Client - SpawnScript:21
 11:40:30.305  koziahss requested  MarkOneDroid  -  Server - MainScript:122
 11:40:30.305  Loading agent.  -  Server - MainScript:142
 11:40:30.306  Loading squad: Sedecim Mark One Agents at location 364, 7.4999995231628, 149.5  -  Server - InfractionHandler:64
 11:40:30.322  Sedecim koziahss loaded. Returning  -  Server - InfractionHandler:81
 11:40:30.322  koziahss loaded...  -  Server - MainScript:144

Video:

Sorry for the long code and thanks for reading.

Edit: FYI what is supposed to happen is that the Camera Changes to view the loaded squad. The squad is then able to be controlled by the player. None of that happens

Hello, from what I understand, it looks like the if statement is not being passed in your server script. The way you could check to see if this is the issue, is to add an else and return false or something along those lines to indicate the error.

It could be a case of the value type, so you can use the Tostring function to ensure that your CharaterRequest variable is a string.

Doesn’t seem to change anything. I get the same outcome. The error on client nor the warning on the server did not print.

Local
local LoadCharacter = ReplicatedStorage.Remotes.LoadCharacter

local Characters = LoadCharacter:InvokeServer("MarkOneDroid")
if not Characters then
	error("Character did not load. Please restart game.")
end
local Leader = InfractionModule:Mobilize(Characters)
Server
LoadCharacter.OnServerInvoke = function(Player,CharacterRequest)
	if tostring(CharacterRequest) == "MarkOneDroid" then
		local Agents = InfractionModule:LoadSquad(Player,workspace.InfractionSpawn.AgentSpawner.Union.Position)
		return Agents
	else
		warn(Player," requested an invalid character type.")
		return
	end
end

The problem is that it does not return anything but RemoteFunction simply does not return anything at all. I have no idea why this isn’t happening. It was working before however it seem to just stop after I fixed some other bugs.

I don’t know how to fix it.

Hmm that’s strange, are you defiantly pathed to the same remote function instance?

Yes. The character loads in it just doesn’t return it to the client

hope this works

----//LocalScript\\---------------------------------------------------------
local InfractionModule = require(script.InfractionController)
local LoadCharacter = ReplicatedStorage.Remotes.LoadCharacter
print(script.ClassName,"running:",script.Name) -- Prints

local Characters = LoadCharacter:InvokeServer("MarkOneDroid")
if Characters then
    print("Agents loaded. Mobilizing unit.") -- Does not print WHY WHY WHY
    local Leader = InfractionModule:Mobilize(Characters)
    print("Agents mobilized and organized.") -- Does not print
end

----//ServerScript\\---------------------------------------------------------
local function loadCharfunction(player, CharacterRequest)
    local Agents
    print(Player,"requested ",CharacterRequest) -- prints correctly
    if CharacterRequest == "MarkOneDroid" then
        print("Loading agent.") -- prints
        Agents = InfractionModule:LoadSquad(Player,workspace.InfractionSpawn.AgentSpawner.Union.Position)
        print(Agents,"loaded...") -- prints correctly
    end
    return Agents
end

LoadCharacter.OnServerInvoke = loadCharfunction

Still doesn’t print.

I think the problem is something else. I don’t know why but it just seams that the remote doesn’t return anything no matter what I do.

Sorry about that I realized the issue.
It was in the handler. Sorry about that. I should have not posted this. I am an idiot.

Removing this for some reason fixed the issue. I have no idea why maybe Seting the character stops the character from loading? Idk

and now I have a bunch more bugs.