Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to clone a script into StarterPlayerScripts?

Asked by 4 years ago

Okay, so I want to clone a localscript from a script in Workspace and put it into a player's StarterPlayerScripts class. I know that the method to do this is to assign the cloned script a new parent saying "script.MYscript:Clone().Parent = _____" except I'm not sure how to fill the blank. I have tried many things, but I either get an error (object is not a valid member of object) or I find out that the cloned script doesn't work the way it should. Please note that I only want to send the script to one player, not all of them at once.

I learned that "script.MYscript:Clone().Parent = Player.PlayerScripts" will not work on account of an error that says, "PlayerScripts is not a valid member of Player." I also added a remote event with a "player" parameter shown below, though I am unsure if this helps or hurts my code. Thoughts/Ideas?

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player)

print(player.Name.." will now receive a script.")
script.MYscriptl:Clone().Parent = _________

end)

0
What is your point for wanting to do this? I feel as though you are over-complicating it. climethestair 1663 — 4y

2 answers

Log in to vote
1
Answered by
DollorLua 235 Moderation Voter
4 years ago

Put the script in StarterPlayerScripts, but then use a RemoteEvent (or two) to travel through the two scripts. Then instead of duplicating it into PlayerScripts, have it already in there (as said in first line) and only have the script do what it needs to do on the remote event. Im not the best scripter so I use 2 remote events (server -> Client -> server) but its not very smart. Use a BindableEvent (I think) to travel between 2 server scripts.

0
It worked! Thank you Dollorman! :) AceGamer247 7 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Just parent it to Player which is == StarterCharacterScripts

Answer this question