✓ Accepted answer
A LocalScript cannot run in workspace, it is a global environment; LocalScripts are meant to run on the local machine, you're trying to handle this within a Server ground.
StarterGui is also a replication container, much like StarterGear, this is not the active location of the Instances you wish to reference—they're moved over to a folder named PlayerGui. To properly interact with the local interface, you must gain access to this container through the Player.
Although, ServerScript's cannot allocate any Player Objects as it is a Server Operation—the Server does not contain a "local Player"—we can still manipulate them if received. Fortunately enough, the .MouseClick signal return the Player Object initiating the ClickDetector.
local clickDetector = script.Parent:FindFirstChildOfClass("ClickDetector")
clickDetector.MouseClick:Connect(function(playerClicked)
local playerGui = playerClicked:FindFirstChild("PlayerGui")
if (playerGui) then
playerGui.ScreenGui.Enabled = true
end
end)
2 comments
Thanks
No problem!