Hello, I have been working on a UI animation module but it has a problem where this always happens:
It always scales the entire UI down to a really small size no matter what facor you send when calling the function here is my code:
local module = {}
local tweenService = game:GetService('TweenService')
local cdSize = false
local cdRotation = false
function module.Shrink(element, Factor, Speed)
if not cdSize then
cdSize = true
local ScaleX = element.Size.X.Scale*Factor
local ScaleY = element.Size.Y.Scale*Factor
local sizeInfo = TweenInfo.new(
Speed,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
true,
0
)
local SizeTween = tweenService:Create(element, sizeInfo, {Size = UDim2.new(ScaleX, ScaleY)})
SizeTween:Play()
wait(3)
cdSize = false
end
end
function module.Rotate(element, Factor, Speed)
if not cdRotation then
cdRotation = true
local RotationInfo = TweenInfo.new(
Speed,
Enum.EasingStyle.Sine,
Enum.EasingDirection.InOut,
0,
true,
0
)
local RotationTween = tweenService:Create(element, RotationInfo, {Rotation = Factor})
RotationTween:Play()
wait(3)
cdSize = false
end
end
return module
The local script:
local module = require(game.ReplicatedStorage.Modules.UIAnimation)
script.Parent.MouseButton1Click:Connect(function()
module.Shrink(script.Parent, .5, .2)
end)
script.Parent.MouseEnter:Connect(function()
module.Rotate(script.Parent, 3,.1)
end)
Thank you!