Is there a way to load the local script on client's playerscripts via Replicatedfirst?

I am developing a mainmodule and I come to this main problem. The first people who joined the server doesn’t get the local script, but the new people does. How would I fix this?

Inside the mainmodule

local loader = script.Parent.Dependencies.ClientBase:Clone()
loader.Parent = game:service'ReplicatedFirst'
loader.Disabled = false

for i,v in next, game:service'Players':GetPlayers() do
  local loade = script.Parent.Dependencies.ClientBase:Clone()
  loade.Parent = v:WaitForChild("PlayerGui") or v:WaitForChild("Backpack")
  loade.Disabled = false

  -- Breaks the local script when reset or respawn again :/
end

You aren’t supposed to use ReplicatedFirst for this kind of thing. PlayerScripts is a non-resetting container for LocalScripts, though it is only client-accessible. Perhaps think about whether you really need the server to be parenting items around.

If you need an ugly workaround, put the LocalScript in a ScreenGui with ResetOnSpawn off. I do believe that just having the client parent the script away would be sufficient enough though. For example, you can make a proxy script that transfers ClientBase to PlayerScripts.

1 Like

I’m considering the fact that your method of putting the local script into the GUI will affect only to the first players while the players who join after them gets the local script separated from the GUI.