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

When I click a part with a click detector the gui is not visible?

Asked by 3 years ago

Hello, I haven't coded in a looong time, I need some to solve this error. I have a click detector that will show a frame in the screengui when the part that is the parent of the clickdetector is clicked, the frame will become visible.

The frame is Visible is set to False

The code

1game.Workspace.Part.ClickDetector.MouseClick:Connect(function()
2    game.StarterGui.ScreenGui.background.Visible = true
3end)

Also this is only supposed to show for the player, any help is great, thank you.

2 answers

Log in to vote
0
Answered by 3 years ago

You should do that on server side, by cloning the gui stored (RepStorage or ServerStorage) to playergui!

Server:

1local gui = --put the local of stored gui as mentioned above
2game.Workspace.Part.ClickDetector.MouseClick:Connect(function(player)
3     guiClone = gui:Clone()
4     guiClone.Parent = player.PlayerGui
5end)

To close it I recommend putting a button the ui itself but you can always remove it from the server!

I did not test it but I`m sure it will work so try it out! If not tell me so I can help you!

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Well, I'm sure a little fix would help;

01local Block = game.Workspace.Part
02local ClickDetector = Block.ClickDetector
03 
04local StarterGui = game:GetService('StarterGui')
05local Gui = StarterGui.ScreenGui.background
06 
07 
08local function MouseClick()
09    Gui.Visible = true
10 
11    if Gui.Visible == true then
12        print('Visible')
13    end
14 
15end
16 
17ClickDetector.MouseClick:Connect(MouseClick)
18-- Note: Maker Sure This Is A LocalScript And Make Sure You Put It Inside The StarterGui

Answer this question