i spent the last 1-2 days making a quick module script for tweening gui objects when hovering with the mouse to excel my scripting skills. the module tweens every gui object u have in a ScreenGui
. i hope this module saves time for u guys when scripting hovering animations!!
- u can add a sound on hover or leave it as nil if you don’t want one.
the module has 3 functions.
:Tween()
- you can animate the gui object with multiple properties.
:Rotate()
- rotates the gui object by the desired amount u give it.
:Scale()
- scale the gui object to expand or shrink it.
parameters for each function:
:Tween()
gui = ScreenGui, | |
---|---|
tweenDuration = number, | |
easingStyle = Enum.EasingStyle, | |
easingDirection = Enum.EasingDirection, | |
repeatCount = number, | |
reverses = boolean, | |
delayTime = number, | |
tweenProperties = {} (a list of desired properties u wish to tween) | |
sound = Sound Instance |
:Rotate()
gui = ScreenGui, | |
---|---|
tweenDuration = number, | |
easingStyle = Enum.EasingStyle, | |
easingDirection = Enum.EasingDirection, | |
repeatCount = number, | |
reverses = boolean, | |
delayTime = number, | |
RotateAmount = number (the rotation u want the gui object to be) | |
sound = Sound Instance |
:Scale()
gui = ScreenGui, | |
---|---|
tweenDuration = number, | |
easingStyle = Enum.EasingStyle, | |
easingDirection = Enum.EasingDirection, | |
repeatCount = number, | |
reverses = boolean, | |
delayTime = number, | |
ScalePercentage = number (The percentage by which the GUI object expands or shrinks.), | |
sound = Sound Instance |
code samples:
:Tween()
local guiTweenModule = require(game.ReplicatedStorage:FindFirstChild("guiTweenModule"))
local soundService = game:GetService("SoundService")
local hoverSound = soundService.hover
local gui = script.Parent
local tweenProperties = {
Rotation = 8,
Size = UDim2.fromScale(0.16, 0.16),
BackgroundColor3 = Color3.new(1, 1, 1),
}
guiTweenModule:Tween(gui, 0.75, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, false, 0, tweenProperties, hoverSound)
:Rotate()
local guiTweenModule = require(game.ReplicatedStorage:FindFirstChild("guiTweenModule"))
local soundService = game:GetService("SoundService")
local hoverSound = soundService.hover
local gui = script.Parent
guiTweenModule:Rotate(gui, 0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, nil, nil, 0.25, 90, hoverSound)
:Scale()
local guiTweenModule = require(game.ReplicatedStorage:FindFirstChild("guiTweenModule"))
local soundService = game:GetService("SoundService")
local hoverSound = soundService.hover
local gui = script.Parent
guiTweenModule:Scale(gui, 0.35, Enum.EasingStyle.Bounce, Enum.EasingDirection.Out, 1, nil, nil, -15, nil)
module script (roblox) :
module script (file) :
guiHoverTweenModule.rbxm (2.8 KB)
the gui + script i used for demonstrations: