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

How do I make a GUI appear on only the screen of the player who presses a button?

Asked by 6 years ago

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?

2 answers

Log in to vote
0
Answered by
Cuirs 10
6 years ago

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.

0
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. JunkellaSyringe 2 — 6y
0
Did you change the GuiObject to the GUI you are wanting to be visible? BunnyFilms1 297 — 6y
0
Also, try making it a local script. BunnyFilms1 297 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

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.

0
or don't add the local just change plr to game.Players.LocalPlayer Goldenkings11 -11 — 6y

Answer this question