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

Why does nothing appear when i use MouseClick ?

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)

2 comments

0

It looks like your trying to clone the entire screen gui which isn't possible

0

i think you should use Activated and oGUI should be game:GetService("ScreenGui")

2 answers

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

2 comments

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?

0

Oh yeah sorry i forgot that sorry

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)

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