Please help, I'm trying to get a GUI to open when a tool is selected but it isn't opening at all. :-(
I get this error when I open the tool: OpenGUI: Attempt to index local 'gui' (a nil value), Line 15 - global LoadGui, Line 28
local replicatedStorage = game:GetService("ReplicatedStorage") local Players = game:GetService("Players") local player = Players.LocalPlayer local mouse = player:GetMouse() playerGui = player.PlayerGui local tool = script.Parent function LoadGui() local BenOVGUI = playerGui:FindFirstChild("BenOVGUI") if BenOVGUI then BenOVGUI.Enabled = true else local cgui = replicatedStorage:WaitForChild("BenOVGUI") local gui = cgui:Clone() gui.Parent = playerGui <--- gui.Enabled = true end end function UnloadGui() local BenOVGUI = playerGui:FindFirstChild("BenOVGUI") if BenOVGUI then BenOVGUI.Enabled = false end end tool.Equipped:connect(function(mouse) LoadGui() <--- end) tool.Unequipped:connect(function() UnloadGui() end)
Is cgui Archivable
by any chance? Anything that is not Archivable
cannot be cloned.