So i have a function in a ModuleScript that loops through every player in the game and inserts MapFocus (a local script) into their "PlayerScripts" for camera manipulation:
function _M.InitiateCamera() for i, v in ipairs(game.Players:GetChildren()) do local MapFocusNew = ServerStorage.MapFocus:Clone() MapFocusNew.Parent = v.PlayerScripts MapFocusNew.Disabled = false wait() MapFocusNew:Destroy() end end
And it works nicely in studio, but not in online mode. The error put out online is "PlayerScripts" is not a valid member of Player. So I attempted to add a WaitForChild as shown:
MapFocusNew.Parent = v:WaitForChild("PlayerScripts")
...which resulted in an infinite wait. To truly see if it was there online, I used the f9 console to print my player's PlayerScripts, and other children of my player, and the PlayerScripts was the only one that threw a not-a-valid-member error.
Am I skipping a step, or should I insert the script elsewhere?
"Unlike instances such as PlayerGui and Backpack, PlayerScripts are not accessible to the server."
This means that you will need to use a local script in order to access PlayerScripts, as the server can't access it.
Source: http://wiki.roblox.com/index.php?title=API:Class/PlayerScripts