LocalScripts cannot run in global environments, that of which includes workspace. They're meant to run on the Client, therefore are only functional in local environments. To solve your issue, simply transfer your code into a SeverScript.
However...
Due to Filtering Enabled, ServerScripts cannot modify local Objects—or without some loopholes—one of which includes the PlayerGui which is used to control the User Interface To gain access to the PlayerGui we need a Player Object, we cannot use .LocalPlayer however since ServerScripts aren't run on local machines, so we'll need to find an alternate way to gain access to the respective Player that needs the GUI Instance enabled.
Luckily, this isn't as hard with ClickDetectors, since they fortunately provide the Player Object as a parameter to the Client that initiated the .MouseClick signal.
Your issues don't stop here however, as we need to solve one last problem. As aforementioned, the PlayerGui is the container used to manage the UI, meaning all GUI Objects are required to be a descendant of this Folder, otherwise they will not not appear or function at all. To initiate a UI, store all Instances relative into StarterGui; they will be actively transfered to the PlayerGui upon joining.
local Clicker = script.Parent.ClickDetector
Clicker.MouseClick:Connect(function(PlayerClicked)
local PlayerGui = PlayerClicked:WaitForChild("PlayerGui")
local Main = PlayerGui:WaitForChild("Main")
Main.Enabled = true
end)
2 comments
you have to parent the gui in the players playergui in order for it to work.
Ensure you put "Main" under StarterGui