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 localscript that opens a GUI when you click on it's parent?[Solved]

I'm trying to make a part that you have to insert an answer into. I added a ScreenGUI to starterGUI, and added this localscript to open it when you click on the script's parent.

local function onMC(playerwhoclicked)
	playerwhoclicked.PlayerGui.submit.TextBox.Visible = true
	playerwhoclicked.PlayerGui.submit.TextButton.Visible = true
end

script.Parent.ClickDetector.MouseClick:connect(onMC)

The problem is, the script doesn't open anything. Also, none of the errors in console link to the script when clicked on. Keep in mind, I don't know anything about localscripts other than that they are scripts that are local.

2 comments

0

Is the script located in a part or in a gui and is the script a local script or server script.

0

It's a local script and of course it's in a part, as he mentioned in his question.

1 answer

--Place your gui in server storage
local name="ScreenGui" -- Place the name of your Gui here

function onclick(plr)
local x = game.ServerStorage.name:Clone()
x.parent = plr.PlayerGui --if your button is derectly in a screen gui then it whould be better if you type x.parent = script.Parent.Parent.Parent
end

script.Parent.ClickDetector.MouseButton1Click:Connect(onclick)

There can be mistakes in this script, if you find mistake please fix it, hope script help. And place it in normal script not in local script.

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