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

Disabling a GUI while opening another?

Asked by 6 years ago

So I have 2 GUI's, a shop GUI and a XP gui. The problem is when I'm entering the shopGUI(It's activated by hitting a brick) the XP Gui is blocking the view of the shop. My question is, what script would be able to disable the "XP GUI" when stepping on the "shopbrick", and when pressing the closebutton on the shop, it would enable the XPGui again?

This is my "OpenShop" script and in the 5th line I tried to add a code, but seems not to work.

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        game.ReplicatedStorage.TriggerCam:FireClient(player)
        game.StarterGui.XPBar.Enabled = false
    end
end)

And here's my "closebutton" on the ShopGUI, see line 21

script.Parent.MouseButton1Click:Connect(function()
    local player = game.Players.LocalPlayer
    local shop = player.PlayerGui.Shop
    local camera = workspace.CurrentCamera
    local item = shop.Item
    local buy = shop.Frame.Buy
    local shadow = buy.Shadow

    if shop.Open.Value == true then
        shop.Open.Value = false
        shop.Frame:TweenPosition(UDim2.new(0,0,1,0),"Out","Quint",1,true)
        item.Value = 1
        camera.CameraType  = Enum.CameraType.Custom
        camera.CameraSubject = player.Character.Humanoid
        camera.CFrame = player.Character.Head.CFrame
        game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
        buy.Text = workspace.Shop:FindFirstChild("Part"..item.Value).ItemPrice.Value
        buy.BackgroundColor3 = Color3.fromRGB(85,255,127)
        buy.BackgroundColor3 = Color3.fromRGB(70, 212, 104)
        shop.Closed.Value = true
        game.StarterGui.XPBar.Enabled = true
        wait(3)
        shop.Closed.Value = false
    end
end)
0
Replace game.StarterGui with player.PlayerGui. The ZIndex property could be useful in this situation. ProtectoidZ 42 — 6y
0
Try using RemoteEvent to enable Gui visibilty thesit123 509 — 6y

Answer this question