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

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

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

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.

3 comments

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.

0

Did you change the GuiObject to the GUI you are wanting to be visible?

0

Also, try making it a local script.

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.

1 comment

0

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.