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