How do I script so it hides this UI when it gets clicked?

Issue resume.

So I did a very simple UI, and I want it to get transparent, unabled, just like I can’t see it anymore. I tried to search how in the Roblox Developer Hub, but it didn’t work. I have tried making my own scripts just thinking how it would hide, but it’s just not working. And I know it’s deeply simple, but I can’t find anything that tells me how.

Script.

The script I have tried.

print("Starting")
script.Parent.MouseClicked:Connect(function(leftClick)
	print("1")
	game.StarterGui.WelcomeGUI.Enabled = false
	print("2")
end)
print("2")

UI construction.

image
image

  1. The event is MouseButton1Click not MouseClicked

  2. The Okie has to be a TextButton not a TextLabel, TextLable doesn’t have a MouseButton1Click event linked to it but TextButton does

  3. Don’t index startergui since that isn’t what the player is seeing. StarterGui gets copied over to the player’s PlayerGui when the player spawns

Once you change just do this

script.Parent.MouseButton1Click:Connect(function()
  script.Parent.Parent:Destroy()
end)
3 Likes

You’re changing the StarterGui, this is not replicated to the Player, Assuming this is a LocalScript, do.

game.Players.LocalPlayer.PlayerGui.WelcomeGUI.Enabled = false

You can just change MouseClick for MouseButton1Click as mentioned by @dandcx

script.Parent.MouseButton1Click:Connect(function()
	game.StarterGui.WelcomeGUI.Enabled = false
end)

Also, It’s really fine doing on StarterGUI as long as it’s a local script.
But you would rather index PlayerGui to avoid spawning with the same changes like

local player = game.Players.LocalPlayer
local playergui = player.PlayerGui
local screengui = screengui
screengui.Parent = playergui

I’m tired and about to go, so I can’t explain, but this sould work:

print("Starting")
script.Parent.MouseButton1UpConnect(function()
	print("1")
	script.Parent.Parent.Parent.Enabled = false
	print("2")
end)
print("2")

Also, the prints are unnecessary and might clog up your clients output, but that’s up to you!

One colon is missing here.

script.Parent.MouseButton1Up:Connect(function()
1 Like
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false

Edit: Nevermind it worked! Thanks so much.

If you’re doing this on a Server Script, the changes won’t be replicated across your client

Do change it to a LocalScript and see if anything changes?