Goal: To clone a local script from ServerStorage and put it in a PlayerScripts.
What exactly are you trying to accomplish? I feel like there are a lot better ways of doing what you are trying to do.
when cloning from a client it clones just for that specific client, which means it won’t be on other clients and its not on the server
In a server script, you can use game.Players.PlayerAdded:Connect(function(player)
Ex:
local Players = game:GetService("Players") -- Player service
local SS = game:GetService("ServerStorage") -- Server Storage
local ScriptToClone = SS:FindFirstChild("Control") -- The script that will be cloned
local function onPlayerAdded(player)
local ClonedScript = ScriptToClone:Clone() -- Clones it and makes it a variable
ClonedScript.Parent = player.PlayerGui -- Gives it to that player when they join (change to just player if you only want it in the player not gui)
end
game.Players.PlayerAdded:Connect(onPlayerAdded)
That would be a function that applies every time the player joins the game
Now I have no idea what your goal is and “control” can be completely unrelated, if you could explain the goal that’d be VERY helpful
Sorry about that - I did not describe my task well enough. I have edited the original post to describe my goal better.
This would not work as I want to put the script in PlayerScripts which is not accessible to the server.
Why? You need to put this in server script service for it to run I believe, cloning scripts from local scripts probably won’t work
- Won’t replicated to the cserver
- You can’t access ServerStorage from the client
Oh, I just realised I could use ReplicatedStorage rather than ServerStorage. I will close the topic now. Thanks for everyone’s help though.