Passed Value is not a function

Hey, I get this error and I am unsure how to fix it.

Error:

Passed Value is not a function

Local Script:

local ui = script.Parent
local FrameHolder = ui.ScreenFrame
local BtnFrame = FrameHolder:WaitForChild("BtnFrame")
local Frames = FrameHolder:WaitForChild("Frames")
local MenuFrame = FrameHolder:WaitForChild("MenuFrame")

local SettingsModule = require(script.SettingsScript)

local SettingsFrame = Frames:WaitForChild("SettingsFrame")

BtnFrame.SettingsBtn.MouseButton1Click:Connect(SettingsModule.OpenSettings)

Module Script:

local Module = {}

local TweenService = game:GetService("TweenService")

local ui = script.Parent.Parent
local FrameHolder = ui:WaitForChild("ScreenFrame")
local BtnFrame = FrameHolder:WaitForChild("BtnFrame")
local Frames = FrameHolder:WaitForChild("Frames")
local MenuFrame = FrameHolder:WaitForChild("MenuFrame")

local SettingsFrame = Frames:WaitForChild("SettingsFrame")

local function OpenSettings()
		SettingsFrame:TweenPosition(
			UDim2.new(0.5, 0,0.5, 0), 
			Enum.EasingDirection.Out, 
			Enum.EasingStyle.Linear, 
			1, 
			true)
end

local function CloseSettings()
		SettingsFrame:TweenPosition(
			UDim2.new(0.5, 0,-2, 0), 
			Enum.EasingDirection.Out, 
			Enum.EasingStyle.Linear, 
			1, 
			true)
end

return Module

Please, help as I am confused, and yes I was searching.

On which line do you get this error?

You are making the function local, which doesn’t add it into the module, so the script didn’t find the function. Do this instead:

function Module.OpenSettings() -- inserts function into module
-- existing code
end
function Module.CloseSettings()
--existing code
end

Ahh. I had a feeling. Would it work if I just returned the function?

return function OpenSettings()
--Code
end

return function CloseSettings()
--Code
end

No, it’s good to do it just like he did vector4_new

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.