Couldn't find a PlayerGui in any player that wasn't me?

Screen Shot 2022-11-24 at 3.43.26 PM
This error only appears for players that are not me, why can’t roblox find their PlayerGui?

Is “Bradings” the player whose PlayerGui you’re trying to get?

It could be that this Bradings player isn’t in the game (yet), therefore it’s an infinite yield.

Can I see the script your using? We an debug together.

Well, they were in the game. It was fully loaded.

LocalScript:

local newplayer = math.random(1, game.ReplicatedStorage.IntValue.Value)
	local player = game.ReplicatedStorage["player"..newplayer]
	game.Players[player.Value].Character:MoveTo(workspace.Block.Position)
	game.Players[player.Value]:WaitForChild("PlayerGui").ScreenGui.TextBox.Visible = true

Script:

game.Players.PlayerAdded:Connect(function(player)
	local newplayer = Instance.new("StringValue")
	game.ReplicatedStorage.IntValue.Value += 1
	newplayer.Value = player.Name
	newplayer.Name = "player"..game.ReplicatedStorage.IntValue.Value
	newplayer.Parent = game.ReplicatedStorage
end)

Is the player’s character moved to the Block position? I’m just trying to get an idea if the code “breaks” when you wait for the PlayerGui or before that.

It is not moved to the block’s position.

But for some reason whenever the script tries to do it for me, it works.

I’m pretty sure that the LocalScript is running its code before you have the values inside of ReplicatedStorage. You could add a wait(#) at the top of the LocalScript for a quick fix.

I would recommend having the server tell the client(s) when the newplayer StringValue is placed into the ReplicatedStorage, because if the LocalScript runs and the data still isn’t there, it will break again.

I checked, and the data is there before the localscript runs.

Btw, I didn’t show the full localscript, but those lines are in a function.

LocalScript can only see Local / Client and not other Player’s PlayerGui.

You can’t access another player’s playergui on the client. Look at this topic, it might help.

This is your answer right here.

You actually can see any players gui folder on the client, though it won’t be updated unless done by a server script.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.