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

Why dosen't this server script recognize PlayerGUI?

So i have this server script called "Game Script" in ServerScriptService but it dosen't recognize PlayerGUI, well if i click on the play button it works but not if i upload the game and play or test the game with 2 players on studio, It's nothing wrong with the plr it's when i test with 2 players on studio then when i go the the Players tab and then on one of the players playerGUI is there but not the guis

Here's the script:

function pMsg(text, t, plr, color)
	if plr ~= nil then
		if plr:findFirstChild("PlayerGui") then
			if plr.PlayerGui:findFirstChild("Main") then
				if plr.PlayerGui.Main:findFirstChild("Message") then
					if color == "Red" then
					plr.PlayerGui.Main.Message.TextColor3 = Color3.new(255/255, 0, 0)	
					elseif color == "Green" then
					plr.PlayerGui.Main.Message.TextColor3 = Color3.new(85/255, 255/255, 0)
					elseif color == "Orange" then
					plr.PlayerGui.Main.Message.TextColor3 = Color3.new(255/255, 170/255, 0)						
					else
					plr.PlayerGui.Main.Message.TextColor3 = Color3.new(255/255, 255/255, 255/255)			
					end
				plr.PlayerGui.Main.Message.Text = text	
				end
			end
		end
	end
	coroutine.resume(coroutine.create(function()
	wait(t)
		if plr ~= nil then
			if plr:findFirstChild("PlayerGui") then
				if plr.PlayerGui:findFirstChild("Main") then
					if plr.PlayerGui.Main:findFirstChild("Message") then
					plr.PlayerGui.Main.Message.Text = ""	
					end
				end
			end
		end	
	end))	
end

2 comments

0

Why not try :WaitForChild("PlayerGui")

0

Then it's infinite yfield wait or something the Guis isnt even in the playergui when you watch as the server

1 answer

✓ Accepted answer

If you'd like to access this with a Server Script, game.Workspace.FilteringEnabled MUST be set to off. This is because PlayerGui is based on the ClientSide. This is part of how FilteringEnabled works.

Additionally, please use WaitForChild when finding PlayerGui, as PlayerGui takes time to load when a player is spawning!

If you'd like to use FilteringEnabled still, you could use it with RemoteEvents/Functions, and fetch PlayerGui from a LocalScript.

If this helped, please press the green verify answer button, it helps other players having the same issue find the answer!

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