This is what I tried:
Player = game.Players.LocalPlayer
function onClick(playerWhoClicked)
Player.PlayerGui.ScreenGui.Enabled = true
end
script.Parent.ClickDetector.MouseClick:connect(onClick)
How can I make this work? What did I do wrong?
This is what I tried:
Player = game.Players.LocalPlayer
function onClick(playerWhoClicked)
Player.PlayerGui.ScreenGui.Enabled = true
end
script.Parent.ClickDetector.MouseClick:connect(onClick)
How can I make this work? What did I do wrong?
Hello! If you haven't already, try making the GUI object visible.
local Player = game:GetService( 'Players' ).LocalPlayer
local function onClick( PlayerWhoClicked )
Player.PlayerGui.ScreenGui.GuiObject.Visible = true
end
script.Parent.ClickDetector.MouseClick:connect( onClick )
Change GuiObject to the name of the object you wish to make visible.
try changing the script to...
local plr = game.Players.LocalPlayer
script.Parent.ClickDetector.MouseClick:Connect(function(onClick)
plr.PlayerGui.ScreenGui.FRAMENAME.Visible = true
end)
and of course change FRAMENAME to whatever the name of the frame is.
or don't add the local just change plr to game.Players.LocalPlayer
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
It still isn't working for some reason. The error message is "Workspace.Part.Script:5: attempt to index upvalue 'Player' (a nil value)" if that helps.
Did you change the GuiObject to the GUI you are wanting to be visible?
Also, try making it a local script.