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

How to make a GUI pop up when clicked a brick?

So I put this script in a click detector that was in a brick but it doesn't work. I want the brick when clicked to show text.

function Clicked(Plr) Plr.PlayerGui.Gui.Frame.Visible=true end

script.Parent.MouseClick:connect(Clicked)

Should I rename theScreenGui to PlayerGui to fix it?

1 comment

1

Please use code blocks when displaying code.

4 answers

You don't need to rename StarterGui to PlayerGui. Roblox automatically does that when the StarterGui is in a player. You need to use :GetPlayerFromCharacter(). Here is how you would use it in your script.

script.Parent.MouseClick:connect(function(Clicked) --This basically activates the function when the thing is clicked.
	game.Players:GetPlayerFromCharacter(Clicked).PlayerGui.Gui.Frame.Visible = true
end)

In the parenthesis of :GetPlayerFromCharacter(), you need the player in the Workspace. Like :GetPlayerFromCharacter(workspace.Player1). Also, you should use :GetPlayerFromCharacter() after the player property like game.Players:GetPlayerFromCharacter().

1 comment

0

MouseClick event already returns the player who clicked.

PlayerGui is a main thing for stuff like this. It pops up only for a specific players GUI. I would do this script below.

INSTRUCTIONS! 1). Make sure this script is a script and that it is in the brick with a ClickDetector 2). Change {GUINAME} to whatever GUI you want to open 3). Change FRAMENAME to the frame inside whatever your GUI you want to open is called! 4). You could also edit inside the frame!

script.Parent.ClickDetector.MouseClick:Connect(function(onClick)
	game.Players.LocalPlayer.GUINAME.FRAMENAME.Visible = true
end)

What does this script mean? 1). game.Players.LocalPlayer goes into the games section {Players} and finds the LocalPlayer clicking the button.

IF YOU NEED ANY FURTHER HELP PLEASE MESSAGE BACK TO THIS. I AM A BEGINNER SCRIPTER AND I HAVE A STRONG PASSION FOR IT SO I AM NOT PERFECT, BUT I AM OKAY WITH GUIS AND EDITING PART'S PROPERTIES AND MAKING MODELS APPEAR AND DISAPPEARING.

Hope this helped, -Goldenkings11

3 comments

0

It worked, but only after a change of a script.

0

I mean, in the game.Players.LocalPlayer.GUINAME.FRAMENAME.Visible = true line, before GUINAME you need to add .PlayerGui

0

where do you make the gui in starter gui, cuz there is no PlayerGui until a player joins

You need to use this script:

script.Parent.ClickDetector.MouseClick:Connect(function(onClick)

    game.Players.LocalPlayer.PlayerGui.YourGuiNameHere.YourFrameNameHere.Visible = true

end)

Remember, the script and clickdetector MUST be in the part you want to be clickable!

1 comment

0

Also where is the V = true, replace the V with Visible.

put this in a locascript in startergui

game.Workspace.Part.ClickDetector.MouseClick:connect(function() --change part to part name
script.Parent.ScreenGui.TextLabel.Visible = true --change screengui and textlabel to the frame you want to be visible

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