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

Why does nothing appear when i use MouseClick ?

Asked by 4 years ago
Edited 4 years ago
1local player = game:GetService("Players").LocalPlayer
2local oGUI = script:FindFirstChild("ScreenGui")
3script.Parent.MouseClick:Connect(function()
4    local GUI = oGUI:Clone()
5    GUI.Parent = player.PlayerGui
6end)

Im trying to make a button , where if you click it , a GUI pops up , but when i tested it , nothing happens and there are no errors , can anybody tell me what's happening ? (Local Script)

0
It looks like your trying to clone the entire screen gui which isn't possible kepiblop 124 — 4y
0
i think you should use Activated and oGUI should be game:GetService("ScreenGui") cherrythetree 130 — 4y

2 answers

Log in to vote
0
Answered by
kepiblop 124
4 years ago
Edited 4 years ago

Your cloning the entire screen gui you need to clone just a single gui for a example try doing this

1local player = game:GetService("Players").LocalPlayer
2local oGuI = game:GetService("StarterGui").Guiyouwannaenable
3script.Parent.MouseClick:Connect(function()
4    local GUI = oGUI:Clone()
5    GUI.Enabled = true
6    GUI.Frame.Visible = true
7    GUI.Parent = player.PlayerGui
8end)

Do not do this though

1local player = game:GetService("Players").LocalPlayer
2local oGuI = game:GetService("ScreenGui").Guiyouwannaenable
3script.Parent.MouseClick:Connect(function()
4oGUI.Enabled = true
5end)

the thing with that is you will have to reset for it to pop up and everybody will see it unless its a local script

0
"ScreenGui" is an object, not a service. Also, cloning a ScreenGui is possible. I assume you're getting mixed up with the StarterGui service and the ScreenGui object? xInfinityBear 1777 — 4y
0
Oh yeah sorry i forgot that sorry kepiblop 124 — 4y
Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

The issue here is that you've got your local script inside workspace. Local Scripts don't run inside workspace so you'll need to parent it somewhere else. Local scripts will only run if it's a descendant of the Player's Backpack, Character Model, PlayerGui, PlayerScripts or the ReplicatedFirst service as you can see here.

I would recommend you to parent your local script inside StarterGui and simply just change your variables.

01local player = game:GetService("Players").LocalPlayer
02 
03workspace.Part.ClickDetector.MouseClick:Connect(function() -- Make sure to change this to where your ClickDetector is located inside your part.
04 
05local oGUI = workspace.Part:FindFirstChild("ScreenGui") -- Make sure to also change this to where your GUI is located inside your part.
06    if oGUI then
07        local GUI = oGUI:Clone()
08        GUI.Parent = player.PlayerGui
09    end
10end)

Answer this question