Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by
iRexBot 147
7 years ago

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)
1
You likely won't need to use a remote event. Can you not just handle it all on the client? Perci1 4988 — 7y
0
Nope. iRexBot 147 — 7y
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. iamnoamesa 674 — 7y
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. kazeks123 195 — 7y
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. Goulstem 8144 — 7y

1 answer

Log in to vote
-1
Answered by 7 years ago
Edited 7 years ago

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)

Ad

Answer this question