Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why won't my local scripts parent be changed it keeps saying cannot find PlayerScripts?

game.Players.PlayerAdded:Connect(function(plr)
wait(5)
Localscript = game.ReplicatedStorage:FindFirstChild("LocalScript")
Localscript.Parent = plr:WaitForChild('PlayerScripts')
end)
	
--But it keeps throwing a errror at me saying 12:03:36.595 - Infinite yield possible on 'Players.KawaiiSatanBoy:WaitForChild("PlayerScripts")'
when i perfectly did everything and it should find it?

2 comments

0

Just put that in StarterPlayer > StarterPlayerScripts folder. It is the same thing.

0

Don't forget to accept my answer if it helps out,

2 answers

✓ Accepted answer

The PlayerScripts folder is created client side. It will not exist on the server side. What you can do is either

A. Parent it to PlayerGui, Backpack, or Character

B. Insert the script in StarterPlayerScripts which itself is under StarterPlayer service

Alright, so if you tested the game, you would see that "PlayerScripts" is Client-Side only. So instead of being in a Server Script, your code should be placed in a LocalScript under StarterGui and be written this way:

local plr = game.Players.LocalPlayer
wait(5)
local Localscript = game.ReplicatedStorage:FindFirstChild("LocalScript")
Localscript.Parent = plr:WaitForChild('PlayerScripts')

This discussion is preserved as it was. New answers, comments, and votes are closed.