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

[SOLVED] Why is GUI is not a valid member of PlayerGui?

The script in ServerScriptService and FilteringEnabled is on.

Part of script:

function playerEnter(newPlayer)
	newPlayer:WaitForChild('PlayerGui')
	local p = newPlayer
	local userId = p.userId
	newPlayer.CharacterAdded:wait()
	repeat wait() until newPlayer.PlayerGui ~= nil
	print("Setting up " .. userId .. "'s resources.")
	newPlayer.PlayerGui.GUI.Loading.Visible = true
	newPlayer.PlayerGui.GUI.Loading.ItemName.Text = "Setting up " .. userId .. "'s resources."
	wait()
	local ranString = RandomString(20)
	local v = Instance.new("Model")
	v.Parent = game.ServerStorage.PlayerDataService
	v.Name = ranString
	
	--newPlayer.PlayerGui.UI.Main.PlayerDataService.Value = v
	
	local v1 = Instance.new("IntValue")
	v2.Parent = v
	v2.Name = "Credits"
	v2.Value = 0	
	
	local v2 = Instance.new("IntValue")
	v6.Parent = newPlayer
	v6.Name = "leaderstats"
	v6.Value = 0
	
	local v3 = Instance.new("IntValue")
	v16.Parent = v6
	v16.Name = "Rank"
	v16.Value = math.floor(v3.Value/1000)
	
	if game:GetService("GamePassService"):PlayerHasPass(newPlayer, 993313196) or newPlayer.Name == "zZGalaxySolarManZz" then
	local v6 = Instance.new("ObjectValue")
	v6.Parent = newPlayer
	v6.Name = "MVP"
	v6.Value = nil			
	end

Output: "GUI is not a valid member of PlayerGui"

Error line is 08: 'newPlayer.PlayerGui.GUI.Loading.Visible = true'

It's not working. Why?

1 comment

0

Read my bio.

1 answer

✓ Accepted answer

Since GUI's are mainly client only, the server (ServerScriptService) cannot access them or edit the contents within them. To make a GUI server wide, you need to use Remote Events. You can find tutorials of remote events on the Guide section of this website, or by browsing the wiki.

2 comments

0

Solved, Thank you much.

0

You're welcome!

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