Why am I getting this error?

This is my current code, at the homeopen line it says this:

user_StudioX.rbxmx.StudioX.StudioX:269: attempt to call a nil value

The functions are in a Module Script:

SCRIPT

StudioXButton.Click:Connect(function()
	StudioXGuiMain.Enabled = not StudioXGuiMain.Enabled
	FunctionsModule.HomeOpen()
	FunctionsModule.AssetOptionsClose()
	FunctionsModule.EasyScriptsClose()
	FunctionsModule.LightingClose()
	FunctionsModule.OtherClose()
	FunctionsModule.ScriptOptionsClose()
	FunctionsModule.ScriptsOptionFrameClose()
	FunctionsModule.SettingsClose()
	FunctionsModule.SupportClose()
	FunctionsModule.homeButtonOpen()
	if StudioXGuiMain.Enabled == false then 
		FunctionsModule.homeButtonClose()
	end
end)

MODULE SCRIPT

local Functions = {}


local StudioXGui = script.Parent.Parent.Parent.StudioXGui
local HomeFrame = StudioXGui.HomeFrame
local SettingsFrame = StudioXGui.SettingsFrame
local ScriptOptionsFrame = StudioXGui.ScriptOptionsFrame
local EasyScriptsFrame = StudioXGui.EasyScriptsFrame
local AssestOptionsFrame = StudioXGui.AssetsOptionsFrame
local SupportFrame = StudioXGui.SupportFrame
local LightingFrame = StudioXGui.LightingFrame
local OtherFrame = StudioXGui.OthersFrame
-- Home Buttons --
local AssestsButton = HomeFrame.AssestsButton
local SupportButton = HomeFrame.SupportButton
local SettingsButton = HomeFrame.SettingsButton
local HomeButton = StudioXGui.home




 function HomeOpen()
	HomeFrame.Visible = true
end

 function HomeClose()
	HomeFrame.Visible = false
end

 function SettingsOpen()
	SettingsFrame.Visible = true
end

 function SettingsClose()
	SettingsFrame.Visible = false
end

 function ScriptOptionsOpen()
	ScriptOptionsFrame.Visible = true
end

 function EasyScriptsOpen()
	EasyScriptsFrame.Visible = true
end

 function EasyScriptsClose()
	EasyScriptsFrame.Visible = false
end

 function ScriptOptionsClose()
	ScriptOptionsFrame.Visible = false
end

 function AssestOptionsOpen()
	AssestOptionsFrame.Visible = true
end

 function AssetOptionsClose()
	AssestOptionsFrame.Visible = false
end

 function ScriptsOptionFrameOpen()
	ScriptOptionsFrame.Visible = true
end

 function ScriptsOptionFrameClose()
	ScriptOptionsFrame.Visible = false
end

 function SupportOpen()
	SupportFrame.Visible = true
end

 function SupportClose()
	SupportFrame.Visible = false
end

 function LightingOpen()
	LightingFrame.Visible = true
end

 function LightingClose()
	LightingFrame.Visible = false
end

 function OtherOpen()
	OtherFrame.Visible = true
end

 function OtherClose()
	OtherFrame.Visible = false
end

 function homeButtonOpen()
	HomeButton.Visible = true
end

 function homeButtonClose()
	HomeButton.Visible = false
end

 function ClickSound()
	local ClickSound = Instance.new("Sound", StudioXGui)
	ClickSound.SoundId = "rbxassetid://177266782"
	ClickSound.Volume = 1
	ClickSound.PlaybackSpeed = 1.2
	ClickSound.PlayOnRemove = true -- Tricks the system to play it on its removal
	wait()
	ClickSound:Destroy()				
end

 function CompleteSound()
	local ClickSound = Instance.new("Sound", StudioXGui)
	ClickSound.SoundId = "rbxassetid://3625285980"
	ClickSound.Volume = 0.5
	ClickSound.PlaybackSpeed = 1.2
	ClickSound.PlayOnRemove = true -- Tricks the system to play it on its removal
	wait()
	ClickSound:Destroy()				
end









return Functions

You’re creating functions in the script, but not in the actual module. Replace the regular functions for this:

function Functions.FuncName()

Example:

function Functions.HomeOpen()
    HomeFrame.Visible = true
end
1 Like

Don’t you have red lines under where you call the functions saying unknown global?

No I do not
image

I will try this out and tell you if it works