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!
-ParkCityUSA
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