Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

ClickDetector script not working?

So I have a script inside a click detector, and when it's clicked it is supposed to make a certain ScreenGUI visible. There were no output errors when I tested it, so I'm not sure what's wrong with it. Can anyone help?

local clickDetector = script.Parent
 
local function onMouseClick(player)
  script.Parent.Parent.Parent.Parent.Parent.StarterGui.Quests.QuestFrame.Visible = true
end
clickDetector.MouseClick:connect(onMouseClick)

1 answer

✓ Accepted answer

When a player is added, the contents of StarterGui gets copied to that player's PlayerGui. Also, you should use the parameter of the onMouseClick() function in order to access that player's PlayerGui.

local clickDetector = script.Parent

local function onMouseClick(player)
	player.PlayerGui.Quests.QuestFrame.Visible = true
end

clickDetector.MouseClick:connect(onMouseClick)

Hope this helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.