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

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

Asked by 5 years ago
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?
0
Just put that in StarterPlayer > StarterPlayerScripts folder. It is the same thing. namespace25 594 — 5y
0
Don't forget to accept my answer if it helps out, User#24403 69 — 5y

2 answers

Log in to vote
1
Answered by 5 years ago

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

Ad
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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')

Answer this question