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

GUI not showing when mouse is clicked?

Asked by 4 years ago

It is printing "Open GUI" but the GUI isn't actually opening.. The part that needs fixing is the last function.

local computerScreen = game.Workspace:WaitForChild("ComputerScreen")
local CursorId = "2287179355"
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.MaxActivationDistance = 10
ClickDetector.CursorIcon = "rbxassetid://"..CursorId
ClickDetector.Parent = computerScreen



local openGUI = Instance.new("BillboardGui")
-- AlwaysOnTop puts GUI on top of everything.
openGUI.AlwaysOnTop = true
openGUI.Name = "OpenComputer"
-- Set Adornee to computerScreen
openGUI.Adornee = computerScreen
openGUI.MaxDistance = 40
openGUI.Size = UDim2.new(1,0,1,0)
openGUI.ExtentsOffset = Vector3.new(0,2,0)
openGUI.Parent = computerScreen


local openText = Instance.new("TextLabel")
openText.FontSize = 9
openText.Size = UDim2.new(1,0,1,0)
openText.TextColor3 = Color3.new(255,255,255)
openText.Font = 10
openText.Text = "Open"
openText.BackgroundTransparency = 1
openText.Visible = false
openText.Parent = computerScreen.OpenComputer

game.StarterGui.ScreenGui.Screen.Visible = false
game.StarterGui.ScreenGui.Screen.Active = false



ClickDetector.MouseHoverEnter:Connect(function()
    openText.Visible = true
end)

ClickDetector.MouseHoverLeave:Connect(function()
    openText.Visible = false
end)

ClickDetector.MouseClick:Connect(function()
    print("Open GUI")
    game.StarterGui.ScreenGui.Screen.Active = true
    game.StarterGui.ScreenGui.Screen.Visible = true
end)

Thanks!

Answer this question