Need help its says possible infinite yield

Hello devs I need help with a script it keeps displaying this warning or bug message when I load the game
image
The Radio UI is in the teams that only get that UI
image
This is the script I am using for my Dealership were I want to disable the GUI and reenabled after closing the dealership GUI but it does not work only works when I place the radio GUI in the SG and start but it needs to be in teams



I need help Because I need this fixed on a other gui

1 Like

I really need help with this now

I canā€™t see the full error, but Iā€™m assuming that it says: Players.GizmosworldYTsub.PlayerGui:WaitForChild(ā€œRadioUIā€).

This is causing an infinite yield because your RadioUI is in a folder called ā€˜Guisā€™ and not in the PlayerGui itself.

will it needs to be in gui folder and placed in teams but I want it to allow me to trigger the dealership on and off if the person is on the team or not

Right, but the error is saying that thereā€™s an infinite yield occurring when trying to wait for ā€œRadioUIā€ in ā€œPlayerGui.ā€ This error only occurs when itā€™s waiting for something that does not even exist which means that RadioUI is not in PlayerGui.

In your blur script on line 2 it reads:

local Radio = script.Parent.Parent:WaitForChild("RadioUI")

Iā€™m not exactly sure where this BlurScript is located, but regardless, this line is attempting to find the UI in a place where it isnā€™t located.

I have a couple of questions myself: where is the RadioUI? Is it being cloned or moved into PlayerGui? Or does it just stay in the Teams?

I would simply put RadioUI in StarterGui, turn off the ResetPlayerGuiOnSpawn property and attach a local script inside it that only opens/closes if a person is on a certain team.

--// Vars
local LocalPlayer = game.Players.LocalPlayer
local TeamService = game:GetService("Teams")
local PoliceTeam = TeamService:WaitForChild("Police")

function CheckTeam()
if LocalPlayer.Team == PoliceTeam then
-- code here
end
end)

CheckTeam() -- runs the function when the player joins
LocalPlayer:GetPropertyChangedSignal("Team"):Connect(CheckTeam) -- runs the function if the player changes team

This can fix it:

local Radio = script.Parent.Parent:FindFirstChild("RadioUI")
if not Radio then
   return Radio
end

You cant put any other instances than Teams in the teams service, I think they get removed when compiling the game(hitting play) - im not sure

1 Like

when the player joins the team they get the radio UI sorry for the late response

so basiclly i want it to disable the radio GUI when the player is in the dealership GUI and after they leave the GUI reenables.But I want it to work if the player has the gui or not the gui is in teams the team that it is in is the team that use that gui or team and then it gets cloned to startergui

local Radio = script.Parent.Parent.Parent:WaitForChild("RadioUI")

i think this should work, you replace the one on the 4th line with this

the 4th line allready has that

Dude did u even listened to me? Just add the UI to StarterGUI and enable/disable it depending in which team they areā€¦

i know but it says infinite yield because itā€™s waiting for an ā€œobjectā€ that doesnā€™t exist in the first place, the difference is that thereā€™s an extra ā€œParentā€

but the dealership gui will reenable the radio GUI after so if I put it in starter GUI the players will get the radio GUI even if not on the team I have tried enabled and disable but it need to only enabled and disable if the player is on that team