Error on function (?)

local Window = {}
Window.__index = Window

function Window.New(Type)
	
	local NewWindow = {}
	NewWindow.Base = _G.UI.Window:Clone()
	NewWindow.Base.Name = Type.."Window"
	NewWindow.WindowFrame = NewWindow.Base.WindowFrame
	NewWindow.Move = false
	
	if Type == "Editor" then
		NewWindow.Inside = _G.UI.Editor:Clone()
	end
	
	NewWindow.Inside.Parent = NewWindow.WindowFrame.Background
	
	setmetatable(NewWindow, Window)
	return NewWindow
end

function Window:Setup()
	
	local A : Frame
	
	--// Move //--
	
	self.WindowFrame:FindFirstChild("Move", true).MouseButton1Down:Connect(Window.Move(self))
	
	--//      //--
	
	
end

function Window:Move()
	
	warn("Move:", self)
	
end

return Window

Prints/Warns out:

I clearly got what I want — it printed out Move; but why is there an error saying “Passed value is not a function”? I just got started on learning Object Oriented Programming so please do keep that in mind.

try this:

function Window:Setup()
    local MoveButton = self.WindowFrame:FindFirstChild("Move", true)
    if MoveButton then
        MoveButton.MouseButton1Down:Connect(function()
            self:Move()
        end)
    end
end

That does work, it’s what I current have on right now. But is it possible to do it without creating a whole new function in

:Connect(function()
-- ABC
)

?

self.WindowFrame:FindFirstChild(“Move”, true).MouseButton1Down:Connect(self.Move)

Window.Move(self) is calling the function instead of passing it as a callback, this is probably why
Q:

A: no

1 Like

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