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