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

PlayerGui won't change visibilty?

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

✓ Accepted answer

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)

9 comments

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.

0

Yes

0

make sure the frame is visible first

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.

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.

0

i don't

0

Wait I do

0

I figured it out now, so don't worry :)

0

k

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