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
local player = game:GetService("Players").LocalPlayer
local oGUI = script:FindFirstChild("ScreenGui")
script.Parent.MouseClick:Connect(function()
    local GUI = oGUI:Clone()
    GUI.Parent = player.PlayerGui
end)

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

local player = game:GetService("Players").LocalPlayer
local oGuI = game:GetService("StarterGui").Guiyouwannaenable
script.Parent.MouseClick:Connect(function()
    local GUI = oGUI:Clone()
    GUI.Enabled = true
    GUI.Frame.Visible = true
    GUI.Parent = player.PlayerGui
end)

Do not do this though

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

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.

local player = game:GetService("Players").LocalPlayer

workspace.Part.ClickDetector.MouseClick:Connect(function() -- Make sure to change this to where your ClickDetector is located inside your part.

local oGUI = workspace.Part:FindFirstChild("ScreenGui") -- Make sure to also change this to where your GUI is located inside your part.
    if oGUI then
        local GUI = oGUI:Clone()
        GUI.Parent = player.PlayerGui
    end
end)

Answer this question