Module Script insertion not parenting a script into the player scripts for players already in the game

  1. What do you want to achieve?
    I am trying to make a module script that can be loaded into other games, and one of the scripts in this module script gets placed in StarterPlayerScripts (its parent is another script, and that script sets the parent to StarterPlayerScripts). I want to make all players already in the game also have this script placed into their player scripts. Players that join the game after the require() of the module script do not have the issue.

  2. What is the issue?
    The player cannot have the script parented to them, because of the fact a server script cannot parent things to PlayerScripts. I am trying to have the script apply to all players in the game that did not rejoin after the script is executed. This does not happen.

  3. What solutions have you tried so far?
    I looked around and found nothing to help. Server Scripts can’t write to PlayerScripts, and players would have to rejoin in order to have the script work because it gets parented to StarterPlayerScripts.

The biggest problem itself is that everything needs to be localized in the module script, as the module is designed to be imported into other games as they need it. I can’t make another script in StarterPlayerScripts to fix this issue.

I also tried making a function that would be called by all players in the game, and would do the following:
local plr = game:GetService(“Players”).LocalPlayer
local PlayerScripts = plr.PlayerScripts
local char = plr.Character
local script = PlayerScripts:WaitForChild(“ScriptName”)

script.Parent = PlayerScripts
script:Clone().Parent = char

This had no effect on the player, except to make them a clone of the script. The module script does not parent the script into the player scripts for players already in the game.

You need to make it a separate script that runs on the server, and use playerAdded instead of PlayerScripts.
local moduleScript = require(…)
local script

– Script is only created once
game:GetService(“Players”).PlayerAdded:Connect(function(player)
if not script then
script = moduleScript:Clone()
script.Parent = script.Parent
end

script:Clone().Parent = player.Character

end)

have u tried storing the modules somewhere else like a folder in replicated storage dedicated to the modules or simply just the player itself? ik this reply is rlly late.