My code doesn't work as a StarterCharacterScript when it seemingly should

currently I’m running a local script that fires a module function, that then fires a remotefunction. the remotefunction goes through and prints on the server, but does not return/print on the client via the module?

modules are placed in replicatedstorage & server script is in serverscriptservice! the localscript requesting the client module is a character script

the localscript requesting the client module is a player script however (this is not ideal)

client module
-- Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Objects
local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera

-- Events
local EventStorage = ReplicatedStorage:WaitForChild("Events")
local RequestAbility = EventStorage:WaitForChild("RequestAbility")

-- Modules
local ModuleStorage = ReplicatedStorage:WaitForChild("Modules")
local GF = require(ModuleStorage:WaitForChild("GlobalFuncs"))

local module = {}

function module.Shapeshift()
	local Character, Humanoid = GF.doesChrExist(LocalPlayer)
	if not Humanoid then return end

	-- play animation when we have an animation module
	-- placeholder stuff, replace when we got a walkspeed module
	local oldspeed = Humanoid.WalkSpeed
	Humanoid.WalkSpeed -= 5
	task.delay(1, function()
		Humanoid.WalkSpeed = oldspeed
	end)

	local Data: {} = RequestAbility:InvokeServer("Shapeshift")

	if Data then
		local FakeCharacter = Data[1]
		local CharacterScripts = Data[2]

		Camera.CameraSubject = FakeCharacter:FindFirstChildOfClass("Humanoid") or nil

		for _, v: LocalScript in CharacterScripts do
			local ving = v:Clone()
			ving.Parent = FakeCharacter
			ving.Enabled = true
		end
	end
end

return module
server module
-- Services
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Objects
local StarterCharacter = script:WaitForChild("StarterCharacter")
local CharacterScripts = script:WaitForChild("StarterCharacterScripts"):GetChildren()

-- Tables
local FallbackShapeshiftIds = {81994966, 184283624, 79560761}

-- Modules
local ModuleStorage = ReplicatedStorage:WaitForChild("Modules")
local GF = require(ModuleStorage:WaitForChild("GlobalFuncs"))

local module = {}

function module.Shapeshift(Player: Player)
	local Character, Humanoid = GF.doesChrExist(Player)
	if not Humanoid or Humanoid.Health <= 0 then return end

	local PossibleChrPool = if #Players:GetPlayers() <= 1 then FallbackShapeshiftIds else Players:GetPlayers()
	GF.Shuffle(PossibleChrPool)

	local ChosenPlr = PossibleChrPool[math.random(1, #PossibleChrPool)]
	local Description = Players:GetHumanoidDescriptionFromUserIdAsync(ChosenPlr)

	-- finally the fake character
	local FakeCharacter = StarterCharacter:Clone()
	local FakeHumanoid = FakeCharacter:WaitForChild("Humanoid")

	FakeCharacter:PivotTo(Character:GetPivot())
	FakeCharacter.Parent = workspace
	Player.Character = FakeCharacter

	FakeHumanoid:ApplyDescriptionAsync(Description)
	return {FakeCharacter, CharacterScripts}
end

return module
server script
-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")

-- Objects
local HuntersFolder = ReplicatedStorage:WaitForChild("Hunters")

-- Events
local EventStorage = ReplicatedStorage:WaitForChild("Events")
local RequestAbility = EventStorage:WaitForChild("RequestAbility")

-- Tables
local LoadedModules = {}

-- Connections
RequestAbility.OnServerInvoke = function(Player: Player, Ability: string, Data: {}?)
	local Module = LoadedModules["Shapeshifter"][Ability]
	if not Module then return end

	local ReturnData = Module.Ability(Player, Data)
	print(ReturnData)

	return ReturnData
end

task.defer(function()
	for _, f in HuntersFolder:GetChildren() do
		local AbilitiesFolder = f:FindFirstChild("Abilities")
		local ServerAbilities = AbilitiesFolder and AbilitiesFolder:FindFirstChild("Server")
		
		if ServerAbilities then
			LoadedModules[f.Name] = {}
			for _, v in ServerAbilities:GetChildren() do
				LoadedModules[f.Name][v.Name] = require(v)
			end
		end
	end
end)

probably missing details so feel free to ask

The issue is that Player.Character = FakeCharacter inside OnServerInvoke destroys your LocalScript mid-yield, so InvokeServer never gets to return. This is a known gotcha - setting the character triggers a script reset on the client, killing the thread that’s still waiting for the response.

The fix is to split it up: use the RemoteFunction only to build and return the data, then fire a separate RemoteEvent from the client after it’s done setting up, which is when the server actually swaps the character.

You’ll need to add an ApplyShapeshift remoteEvent to your Events folder, then here are the corrected scripts:

Client Module:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera

local EventStorage = ReplicatedStorage:WaitForChild("Events")
local RequestAbility = EventStorage:WaitForChild("RequestAbility")
local ApplyShapeshift = EventStorage:WaitForChild("ApplyShapeshift")

local ModuleStorage = ReplicatedStorage:WaitForChild("Modules")
local GF = require(ModuleStorage:WaitForChild("GlobalFuncs"))

local module = {}

function module.Shapeshift()
	local Character, Humanoid = GF.doesChrExist(LocalPlayer)
	if not Humanoid then return end

	local oldspeed = Humanoid.WalkSpeed
	Humanoid.WalkSpeed -= 5
	task.delay(1, function()
		Humanoid.WalkSpeed = oldspeed
	end)

	local Data: {} = RequestAbility:InvokeServer("Shapeshift")

	if Data then
		local FakeCharacter = Data[1]
		local CharacterScripts = Data[2]

		Camera.CameraSubject = FakeCharacter:FindFirstChildOfClass("Humanoid") or nil

		for _, v: LocalScript in CharacterScripts do
			local ving = v:Clone()
			ving.Parent = FakeCharacter
			ving.Enabled = true
		end

		ApplyShapeshift:FireServer(FakeCharacter)
	end
end

return module

Server Module:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local StarterCharacter = script:WaitForChild("StarterCharacter")
local CharacterScripts = script:WaitForChild("StarterCharacterScripts"):GetChildren()

local FallbackShapeshiftIds = {81994966, 184283624, 79560761}

local ModuleStorage = ReplicatedStorage:WaitForChild("Modules")
local GF = require(ModuleStorage:WaitForChild("GlobalFuncs"))

local module = {}

function module.Shapeshift(Player: Player)
	local Character, Humanoid = GF.doesChrExist(Player)
	if not Humanoid or Humanoid.Health <= 0 then return end

	local PossibleChrPool = if #Players:GetPlayers() <= 1 then FallbackShapeshiftIds else Players:GetPlayers()
	GF.Shuffle(PossibleChrPool)

	local ChosenPlr = PossibleChrPool[math.random(1, #PossibleChrPool)]
	local Description = Players:GetHumanoidDescriptionFromUserIdAsync(ChosenPlr)

	local FakeCharacter = StarterCharacter:Clone()
	local FakeHumanoid = FakeCharacter:WaitForChild("Humanoid")

	FakeCharacter:PivotTo(Character:GetPivot())
	FakeCharacter.Parent = workspace

	FakeHumanoid:ApplyDescriptionAsync(Description)
	return {FakeCharacter, CharacterScripts}
end

return module

Server Script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local HuntersFolder = ReplicatedStorage:WaitForChild("Hunters")

local EventStorage = ReplicatedStorage:WaitForChild("Events")
local RequestAbility = EventStorage:WaitForChild("RequestAbility")
local ApplyShapeshift = EventStorage:WaitForChild("ApplyShapeshift")

local LoadedModules = {}

for _, f in HuntersFolder:GetChildren() do
	local AbilitiesFolder = f:FindFirstChild("Abilities")
	local ServerAbilities = AbilitiesFolder and AbilitiesFolder:FindFirstChild("Server")

	if ServerAbilities then
		LoadedModules[f.Name] = {}
		for _, v in ServerAbilities:GetChildren() do
			LoadedModules[f.Name][v.Name] = require(v)
		end
	end
end

RequestAbility.OnServerInvoke = function(Player: Player, Ability: string, Data: {}?)
	local Module = LoadedModules["Shapeshifter"][Ability]
	if not Module then return end
	return Module.Ability(Player, Data)
end

ApplyShapeshift.OnServerEvent:Connect(function(Player: Player, FakeCharacter)
	Player.Character = FakeCharacter
end)