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)

1 comment
It was, but I was able to have it cloned while still being Archivable before. I added in Adonis Admin to my game and it broke the script, and it's giving me errors but I really like the admin so..