I need to be able to call a module script as a chosen client from a different client. I have tried 1. Imagining script interactions that would allow me to do such a thing (to no avail) and 2. Searched the internet for people with a similar problem and for features that would allow me to fix this issue (again, to no avail).
So, does anyone know of any features or have any ideas to solve this issue? Please don't suggest alternatives as I already have some ideas, but being able to solve this problem would simplify the situation pretty significantly.
Example (not the actual code but proves the same point):
Script in StarterCharacterScripts:
local uis = game:GetService("UserInputService")
local players = game:GetService("Players")
local repStorage = game:GetService("ReplicatedStorage")
local module = require(repStorage.module)
-- Get player that isn't local player
function getOtherPlayer()
if #players:GetChildren() > 1 then
for i, v in pairs(players:GetChildren()) do
if v ~= players.LocalPlayer then
return v
end
end
end
return nil
end
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
local player = getOtherPlayer()
if player ~= nil then
module.test(player)
else
error("only 1 player!")
end
end
end)
Script in ReplicatedStorage:
local module = {}
local players = game:GetService("Players")
function module.test(player)
-- Meant to set the referenced player's (not the calling player's)
-- CameraSubject to their HumanoidRootPart, which does not work
-- due to the modulescript being called from the wrong client.
workspace.CurrentCamera.CameraSubject =
player.Character.HumanoidRootPart
end
return module
Sorry if my forum etiquette is bad, I'm not very good with this stuff. Please let me know if I missed anything.
EDIT (for clarification):
In response to AlexanderYar:
Sorry for being unclear, let me clarify.
The base concept is: whenever a module script is called from a script, it imitates the script's type. For example, when it is called from a server script, it runs as if it were a server script. However, when it is called from a local script, it runs on the computer of client who called it; this is the problem. I want to be able to call a module script and have it run on a specific client's computer.
In the example code, I try to change the "other player"'s camera to their humanoidrootpart, but because the module script only runs on the computer of the client who called it, it changes the calling player's camera instead of the "other player"'s camera (workspace.currentcamera is dependent on who calls it). Ideally, I would be able to call a module script from client one, and have it run on client two's computer. I don't care how it is accomplished (remote events, obscure services, etc.) as long as it works and isn't laggy.
I'm not suggesting you don't know this stuff, I'm just terrible at putting it into words. Let me know if this helped.

1 comment
I edited my answer, hope it helps you. if not, please leave a comment. PS: I don't get notified of comments on other ppl questions/answers, so best way to contact me is to add a comment to my answer