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

I am getting a "Infinite Yield" on AirDropNoticeGui, Can you show me what I am doing wrong?

I am getting a "Infinite yield" error on AirDropNoticeGui I do not understand why I can see it in PlayerGui. I have also tried it this way: Nam.PlayerGui.AirDropNoticeGui.Main.Visible = true Then I get an error saying it don't exist.

local plr = game:GetService("Players")

for p, Nam in pairs(plr:GetChildren()) do
	
	Nam.PlayerGui:WaitForChild("AirDropNoticeGui").Main.Visible = true
		print("1st")
		wait(5)
	Nam.PlayerGui:WaitForChild("AirDropNoticeGui").Main.Visible = false
		print("2nd")
		
	break
end
	wait(15,50)
end

10 comments

0

Then it doesn't exist. The error answers your question.

0

Also I am trying to get a GUI to show for all players. The Gui called "AirDropNoticeGui" is in StarterGui so all player do spawn with it.

0

I understand it does not see it but As I run the game I can see it in the playergui. I even copy and pasted the name to make sure it was right.

0

I didn't know you could use starter gui like that. I will give that a try thank you.

0

Ok I tried to do in StarterGui and that does work in StarterGui does no show on client side. SO it has to change it in PlayerGui I still do not understand Why it is not finding it when I can see it there.

0

An Infinite yield means that the child being called is taking too long to be called. Try adding a wait() function instead of waitforchild() and make sure that the spelling is correct.

0

Are you doing this in a server (normal) script? Server scripts can’t access PlayerGui, only local scripts can.

0

Yes I am using a Script not a LocalScript.

0

What I am trying to do is a model is being placed it the workspace that works fine, Then I am trying to notify all players with a Gui.

0

^ Do all this in a local script then. Check if the model is placed then show the GUI through “game.Players.LocalPlayer.PlayerGui” and etc.

1 answer

✓ Accepted answer

I see your issue here..

so what you're wanting is this

Server Script--

local notifyEvent = Instance.new('RemoteEvent',game.ReplicatedStorage)
notifyEvent.Name = 'notifyEvent

while wait(15,50) do
	notifyEvent:FireAllClients()
end

Local Script --

local Player = game:GetService('Players').LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local Adng = PlayerGui:WaitForChild('AirDropNoticeGui')
local notifyEvent = game:GetService('ReplicatedStorage'):WaitForChild('notifyEvent')

notifyEvent.OnClientEvent:Connect(function()
	Adng.Main.Visible = true
	wait(5)
	Adng.Main.Visible = false
end)

If you have any question Please feel free to ask!

3 comments

0

What this does is it creates a RemoteEvent which gets fired every 15 to 50 seconds to every client in the game; telling each client to make that gui visible and then after 5 seconds makes that gui not visible again.

0

Thank you very much now I can see what I have done wrong.

0

You are very welcome! Yeah, You're wanting PlayerGui not StarterGui ;P Anything within StarterGui gets replicated to every players PlayerGui when they join the game!

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