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

Filtering Enabled Open/Close Gui button won't work in-game?

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

1

You likely won't need to use a remote event. Can you not just handle it all on the client?

0

Nope.

1

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.

0

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.

0

You can't handle client's UI on the server - you gotta reverse what you're doing and change the visibility in an OnClientEvent evnet.

1 answer

Heres Something you could do instead First make a Text Button in your frame Then A Script in that Text Button after Putting it where you want and resizing it You write in the script:

script.Parent.MouseButton1Click:connect(function(player) local PlayerButton = player.PlayerGui.ScreenGui.Frame.TextButton local TargetFrame = PlayerButton.Parent.Parent.TargetFrame

if TargetFrame.Visible == false then
	TargetFrame.Visible = true
	PlayerButton.Text = "Close TargetFrame"
else
	TargetFrame.Visible = false
	PlayerButton.Text = "Open TargetFrame"
end

end)

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