Gui opens only once

I want to make if you click on the part with image that in workspace, you can see this image from gui, and if you click on this gui - it dissapears. It works only one time and then doesn’t. Here it is:

This is the script for workspace image:

script.Parent.ClickDetector.MouseClick:Connect(function(Player)
local imageInGui = Player.PlayerGui.ScreenGui.Image
imageInGui.Visible = true
end)

This is a LocalScript for Gui:

local mouse = game.Players.LocalPlayer:GetMouse()

mouse.Button1Down:Connect(function()
script.Parent.Visible = false
end)

And i saw this in my output:

RunService:UnbindFromRenderStep removed different functions with same reference name utility-focus-state-inspect-Task_1226 2 times.

I guess that’s because i put the script in the local script, but i can only detect a mouse in LocalScript. Help

Apparently it’s a different UI element being toggled invisible, maybe one of its ancestors. Maybe check which UI is being toggled by going through the Explorer?

I recommend checking the ‘hierarchy’ if i spelled it wrong sorry, for the gui and scripts, it might toggle the wrong elements, and your error that you provided has nothing to do with the issues you’re experiencing, i’ve seen it many times too, and my only guess is that it is a roblox background process error.

When you set the image’s ‘Visible’ property to ‘false’ on the client the server still sees it as ‘true’. You need to set the image’s ‘Visible’ property either on the server only or on the client only. This can be achieved via a ‘RemoteEvent’ instance.

1 Like

If you talking about that i have multiple images with name “Image”, it’s not, i have Image, Image2 etc.

зображення_2024-04-19_132058403
This?

Oh, i was need just to change the Image to the ImageButton, change LocalScript to script and everything works (because i don’t need to detect mouse with ImageButton)

1 Like

Did you put any scripts in the imagePart? Could you also show us what is inside all of the scripts that are related to the part?