So I've been experimenting with trying to show gui when I click on an object. I found that disabling the gui and enabling the gui hides it and shows it. So this is the script I tried:
local ClickDetector = workspace.Volcano.Keypad.ClickDetector function onMouseClick() game.StarterGui.Keypad.Enabled = true end ClickDetector.MouseClick:connect(onMouseClick)
This enables the gui but it doesn't show.
You might want to use PlayerGui, so it only works for the player who clicked it.
To get the player, we can use a player added event.
Script:
game.Players.PlayerAdded:Connect( function(player) print(player.Name) end )
Now, once we've done that, we'll have to detect if the player clicks the part.
game.Players.PlayerAdded:Connect( function(player) print(player.Name) local ClickDetector = workspace.Volcano.Keypad.ClickDetector function onMouseClick() print("Clicked)") end ClickDetector.MouseClick:Connect(onMouseClick) end )
After that, we'll have to make it toggle enabled. To do this, we'll just have to do an if statement detecting if it's enabled or not.
game.Players.PlayerAdded:Connect( function(player) print(player.Name) local ClickDetector = workspace.Volcano.Keypad.ClickDetector function onMouseClick() print("Clicked)") if player.PlayerGui.Keypad.Enabled == false then player.PlayerGui.Keypad.Enabled = true else player.PlayerGui.Keypad.Enabled = false end end ClickDetector.MouseClick:Connect(onMouseClick) end )
Accept the answer if it worked.