So I'm making a script that is FE it will turn a player gui off/on. It works in roblox studio but it doesn't work for in-game. I see this is console when I click it "Infinite Yield Possible on 'Players.iRexBot.PlayerGui:WaitForChild("ShopGui")" Can anyone possibly fix it?
local Storage = game:GetService('ReplicatedStorage')
local OpenEvent = Storage:WaitForChild('OpenShop')
--Core
function onFired(player, status)
local playergui = player:WaitForChild('PlayerGui')
local Shop = playergui:WaitForChild('ShopGui')
local Frame = Shop:WaitForChild('ShopFrame')
local Button = Shop:WaitForChild('OpenShop')
if Frame.Visible==true then
print('Opened')
Frame.Visible=false
elseif Frame.Visible==false then
print('Closed')
Frame.Visible=true
end
end
OpenEvent.OnServerEvent:Connect(onFired)

5 comments
You likely won't need to use a remote event. Can you not just handle it all on the client?
Nope.
Filtering enable is to block client/server sided changes. For player guis, that should be nearly all done in the client. When they try to purchase something in the shop gui for example, THEN you would use remotes.
I can only explain that (in the script, line 07) it waits (yields) till "ShopGui" is found in the specified location, but doesn't find it and hangs up.
You can't handle client's UI on the server - you gotta reverse what you're doing and change the visibility in an
OnClientEventevnet.