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

PlayerGui won't change visibilty?

Asked by 3 years ago
Edited 3 years ago

I am working on a home store, and I want to open a buy/try GUI by changing its visibility, but it doesn't work for me. It only works if I open the GUI manually from the explorer while in-game.

p = game.Players.LocalPlayer
Frame = p.PlayerGui.BuyGUI.Frame

script.Parent.ClickDetector.MouseClick:Connect(function()
    Frame.Visible = true
end)

1 answer

Log in to vote
0
Answered by 3 years ago

Put Buygui in click detector, and put local script in StarterGui.

local player = game.Players.LocalPlayer -- Define the local player
local playerGui = player:WaitForChild("PlayerGui") -- Define the player's player gui

local part = workspace:WaitForChild("Part") -- Change the 'part' to your part
local cd = part:FindFirstChild("ClickDetector") -- Define the click detector

local gui = cd:FindFirstChild("BuyGui") -- Define your gui (insert it to part's click detector)

cd.MouseClick:Connect(function()
    if not playerGui:FindFirstChild(gui.Name) then
        gui:Clone().Parent = playerGui
    elseif playerGui:FindFirstChild(gui.Name) then
        playerGui:FindFirstChild(gui.Name):Destroy()
    end
end)
0
Hmm, it doesn't work for me. I think it's because the gui is in workspace, and not in the StarterGui. So it won't get in the PlayerGui. purplxboi 2 — 3y
0
Yes purplxboi 2 — 3y
0
make sure the frame is visible first vincentthecat1 199 — 3y
0
The script it self does not make the frame visible it puts the ui in playergui when the frame is visible, and when you click the brick again it gets destroyed. vincentthecat1 199 — 3y
View all comments (5 more)
0
Oh yeah sorry I was just dumb and made a mistake. I got it to work now, thank you so much! But do you know how do locate a model in workspace that doesn't have a name? Or at least just disable the display name of a Humanoid. purplxboi 2 — 3y
0
i don't vincentthecat1 199 — 3y
0
Wait I do vincentthecat1 199 — 3y
0
I figured it out now, so don't worry :) purplxboi 2 — 3y
0
k vincentthecat1 199 — 3y
Ad

Answer this question