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?
01 | local Storage = game:GetService( 'ReplicatedStorage' ) |
02 | local OpenEvent = Storage:WaitForChild( 'OpenShop' ) |
03 | --Core |
04 |
05 | function onFired(player, status) |
06 | local playergui = player:WaitForChild( 'PlayerGui' ) |
07 | local Shop = playergui:WaitForChild( 'ShopGui' ) |
08 | local Frame = Shop:WaitForChild( 'ShopFrame' ) |
09 | local Button = Shop:WaitForChild( 'OpenShop' ) |
10 | if Frame.Visible = = true then |
11 | print ( 'Opened' ) |
12 | Frame.Visible = false |
13 | elseif Frame.Visible = = false then |
14 | print ( 'Closed' ) |
15 | Frame.Visible = true |
16 | end |
17 | end |
18 | OpenEvent.OnServerEvent:Connect(onFired) |
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
1 | if TargetFrame.Visible = = false then |
2 | TargetFrame.Visible = true |
3 | PlayerButton.Text = "Close TargetFrame" |
4 | else |
5 | TargetFrame.Visible = false |
6 | PlayerButton.Text = "Open TargetFrame" |
7 | end |
end)