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

GetChildren not working as intended?

I have a :GetChildren() set up to detect if some text is equal to the amount of children, I am using a server script in server script service, I don't know what I'm doing wrong, I get no errors.

game.StarterGui.Game.Frame.Night.PlayersReady.Changed:Connect(function()
	local ign = game.ReplicatedStorage.InGameNames:GetChildren()

	if game.StarterGui.Game.Frame.Night.PlayersReady.Text == #ign then
		game.ReplicatedStorage.Values.DayNight.Value = true
	end
end)

3 comments

1

You can't use StarterGui, you need to use PlayerGui as that one actually updates

0

game.PlayerGui didn't work, it says it isn

0

isn't a member of data model

1 answer

You misunderstand StarterGui. Starter Gui is just the area that you put GUIs, in which them automatically get added to every played. I can see in the comments, you also tried game.Playergui, but again, you are misled.

The correct term for reaching a player's gui is game.Players.[Specificplayer].PlayerGui

to reach every player's gui, do the following

for i,v in pairs(game.Players:GetChildren()) do
	PlayerGui = v:GetFirstChild("PlayerGui")
	--Do whatever you want with the gui here--

Hope this solves your question, please comment if you have any queries or confusion. :)

1 comment

0

The server can't access PlayerGui's descendants

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