Ui Animation Module

Hello There!, Im currently making a ui animation moudle. However, i keep getting this error in the local script that runs the tween when clicked:
Players.ScxiptedShark.PlayerGui.ScreenGui.TextButton.LocalScript:3: attempt to call a nil value

Heres the local script:
local module = require(game.ReplicatedStorage:WaitForChild(“UiAnimations”))
script.Parent.MouseButton1Click:Connect(function()
module.Shrink(script.Parent, .5, .2)
end)

And here’s the module script:

local moudle = {}

local TweenService = game:GetService(“TweenService”)

local SizeCoolDown = false

local function Shrink(element, Factor, speed)
local SizeX = element.Size.X.ScaleFactor
local SizeY = element.Size.Y.Scale
Factor

local ShrinkInfo = TweenInfo.new(
	speed,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.InOut,
	0,
	true,
	0
)


local ShrinkTween = TweenService:Create(element, ShrinkInfo, {Size = UDim2.new(SizeX,0,SizeY,0)})

ShrinkTween:Play()

end

return moudle

1 Like

You made the Shrink function local in the ModuleScript, remove the local infront of module.Shrink

1 Like

i believe i tried this before. ill try again tho.

nope it didn’t work. same error. the error is in the local script.

Wait wait I see the issue now, it’s that plus you only wrote function Shrink, it’s supposed to be moudle.Shrink, writing it how you wrote it made the modulescript think it’s a function only for it, not for use in other scripts

1 Like

what script is that? i don’t see it.

The modulescript where you made the Shrink function, you didn’t prefix it with moudle.

It’s supposed to be this

function moudle.Shrink(element, Factor, speed)
	local SizeX = element.Size.X.ScaleFactor
	local SizeY = element.Size.Y.ScaleFactor

	local ShrinkInfo = TweenInfo.new(
		speed,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut,
		0,
		true,
		0
	)

	local ShrinkTween = TweenService:Create(element, ShrinkInfo, {Size = UDim2.new(SizeX,0,SizeY,0)})

	ShrinkTween:Play()
end
1 Like

if he’s writing a function in a module script, it’s function module.Shrink()

(my bad, just saw that in the code you posted)

1 Like

He wrote it as moudle in his modulescript

Oops, sent that right as you edited it. No worries!

1 Like

THANKS! It worked! :slight_smile:

1 Like

Alright gotcha, apologies, thought there was a misunderstanding.

2 Likes

Anytime! if you have anymore issues don’t be afraid to make another post!

1 Like

probably with the next one im making.

1 Like

It’s all good! Sometimes we don’t see the obvious things until we look carefully!

2 Likes