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

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

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:

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

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;

local Block = game.Workspace.Part
local ClickDetector = Block.ClickDetector

local StarterGui = game:GetService('StarterGui')
local Gui = StarterGui.ScreenGui.background


local function MouseClick()
    Gui.Visible = true

    if Gui.Visible == true then
        print('Visible')
    end

end

ClickDetector.MouseClick:Connect(MouseClick)
-- Note: Maker Sure This Is A LocalScript And Make Sure You Put It Inside The StarterGui

Answer this question