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

How do I make a localscript that opens a GUI when you click on it's parent?[Solved]

Asked by 6 years ago
Edited 6 years ago

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.

0
Is the script located in a part or in a gui and is the script a local script or server script. Earthkingiv 51 — 6y
0
It's a local script and of course it's in a part, as he mentioned in his question. LeadRDRK 437 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
--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.

Ad

Answer this question