How to run a function in a module script

I’m making a UI module for my system, and because theres no way to change the hover icon for TextButton im using TextLabel as a “button”.

Now normally for a button you’d do,

button.MouseButton1Down:Connect(function()

end)

Now I can’t do MouseButton1Down on a TextLabel because… its not a button.

here is the ModuleScript:

function module:ConnectButton(textLabel: TextLabel, function)
	textLabel.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then

		end
	end)
end

The LocalScript:

local module = require(game.ReplicatedStorage.UIhandler)
local new = module.new()

--new:buttonAllTagged()

new:ConnectButton(script.Parent, function()
	print("XD")
end)
1 Like

I figured it out,

All you have to do in the module script is do

parameter()

in this case id do

ModuleScript:

function module:ConnectButton(textLabel: TextLabel, callback)
	textLabel.InputBegan:Connect(function(input)
		if input.UserInputType == Enum.UserInputType.MouseButton1 then
           callback()
		end
	end)
end

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