I'm making a 'purchase/shop' screen for a Roblox game, but I'm having trouble opening it from a localscript in a part.
I'm not sure exactly what the problem is, I'm fairly beginner to Roblox development.
I used a similar script for closing the GUI (which worked well) but when prompted it will not open or make any sound. Screenshot of explorer
Here's the code I've written (also displayed in the screenshot if I've typo'd it):
-- localScript
local clicky = game.Workspace
local GUI = game.Players.FindFirstChild("menuGUI")
local bloopSound = game:GetService("SoundService").UIbloop
function openfromprompt()
GUI.Visible = true
bloopSound:Play()
end
clicky.ClickDetector.MouseClick:Connect(openfromprompt)
And the error message as follows: (line 11 is the Mouseclick:connect line)
Exception hit: LocalScript:11 attempt to index nil with 'ClickDetector'
The Gui is not located inside the player itself. it is actually inside Player.PlayerGui
. but other than that if this is the LocalScript inside the Gui you could just do script.Parent
:
-- // Variables
local Clicky = workspace:FindFirstChild("Upgrades");
local Gui = script.Parent;
local Bloop = game:GetService("SoundService").UIbloop;
Clicky.ClickDetector.MouseClick:Connect(function()
Gui.Visible = true;
Bloop:Play();
end)