Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ClickDetector script not working?

Asked by 8 years ago

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

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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.

Ad

Answer this question