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:7: Attempt to index local 'gui' (a nil value), global LoadGui OpenGUI: Line 21
And this error when I close the tool: OpenGUI:16: Attempt to index local 'gui' (a nil value), global UnloadGui: Line 25
local player = game.Players.LocalPlayer
function LoadGui()
repeat wait() until player.Character
if not player.PlayerGui:findFirstChild("BenOVGUI") then
gui = game.ReplicatedStorage.BenOVGUI:Clone()
gui.Parent = game.Players.LocalPlayer.PlayerGui
print("Gui placed in ".. player.Name)
else
gui.Enabled = true
print("Gui Enabled.")
end
end
function UnloadGui()
gui.Enabled = false
print("Gui Disabled.")
end
script.Parent.Parent.Equipped:connect(function()
LoadGui() <--?
end)
script.Parent.Parent.Unequipped:connect(function()
UnloadGui() <--?
end)

3 comments
The clone might be incorrect.
What do you mean?
Make sure BenOVGUI exists in ReplicatedStorage (Case sensitive). Also, use game:GetService("ReplicatedStorage") instead of game.ReplicatedStorage.