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

WaitForChild() is not working properly?

I know what I'm going and I have no clue what is going wrong.

Here is the start of the corrupt LocalScript under StarterPlayerScripts.

local Player = game.Players.LocalPlayer;

local ServerStorage = game:GetService('ServerStorage');
local ContentProvider = game:GetService('ContentProvider');

local Events = ServerStorage:WaitForChild('Events');
local Replications = ServerStorage:WaitForChild('Replications');

local PlayerGui = Player:WaitForChild('PlayerGui');
local ViewPart = game.Workspace:WaitForChild('ViewPart');
local Camera = game.Workspace.CurrentCamera;

The Events variable waits infinitely for the Events (folder), although the Events folder is clearly there, no other script moves or removes the folder 'Events'.

I've also done this in a ServerScript and the WaitForChild() would not detect the 'PlayerGui' in the player.

It works in Studio, but not in the game itself, it'd be nice to know how to get passed this, please HELP! :)

1 answer

✓ Accepted answer

LocalScripts don't have access to ServerStorage. That's why it's ServerStorage.

Scripts don't have access to PlayerGui, because it's located on the player's screen.


Resources used by LocalScripts should live in ReplicatedStorage.

Resources in ServerStorage can only be used by Scripts and not LocalScripts.

1 comment

1

Server scripts do however have access to PlayerGui :) You can parent local scripts etc from server storage into it from a server-side script.

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