ScreenGui Troubles in Workspace

I’ve had a problem for some time and I thought I’d get it out of the way before 2023.
Whenever I try to edit or open anything in StarterGui using a script in the workspace it doesn’t work.
I also tried to put the code in a LocalScript but to no avail. Here’s a little snippet of code I tried to use just in case:

local Text = game.StarterGui.ScreenGui.TextLabel
local ClickDet = script.Parent.HumanoidRootPart.ClickDetector

ClickDet.MouseClick:Connect(function()
	Text.Visible = true
end)

Thanks for everything and have a happy new year! :wink:
-ParkCityUSA

Could you possibly expand?
Mayby a picture of your StarterGui in the explorer?

Local Scripts can only be used in Starter Player or starter GUI, not in workspace.
I suggest using remote events

From what I understand, you are trying to open a UI upon clicking a clickdetector, in that case you should look into the player’s playergui.

local Player = game:GetService('Players').LocalPlayer
local TextLabel = Player.ScreenGui.TextLabel
local ClickDet = script.Parent.HumanoidRootPart.ClickDetector

ClickDet.MouseClick:Connect(function()
	TextLabel.Visible = true
end)

If you wanted to use it in a server script it’d look different

local ClickDet = script.Parent.HumanoidRootPart.ClickDetector

ClickDet.MouseClick:Connect(function(Player)
	local TextLabel = Player.PlayerGui.ScreenGui.TextLabel
	TextLabel.Visible = true
end)

I’d recommend using a serverscript based on where you are placing the script.

What you are doing is essentially just changing the UI in StarterGui but not the Player’s UI

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.