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

"PlayerScripts" doesn't exist in players in online mode?

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?

1 answer

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