Gui tween is broken

  1. i have a gui and and when mouse enters it plays an tween but tween not works perfectly

video:

script:


local holder = script.Parent.Holder
local ts = game:GetService("TweenService")
local mainUi = holder["Main pet menu"]
local hoverSound = script.ui_hover_ugd
local easingStyle = Enum.EasingStyle.Back
local easingDirection = Enum.EasingDirection.Out
local endingSizeimage = UDim2.new({0.069, 0},{0.173, 0})
local StartingSizeimage = UDim2.new({0.061, 0},{0.16, 0})
local hoverButtonGradient = ts:Create(script.Parent.ImageButton.UIGradient, TweenInfo.new(0.2, easingStyle, easingDirection), {Offset = Vector2.new(0,1)})
local hoverButtonGradient2 = ts:Create(script.Parent.ImageButton.UIGradient, TweenInfo.new(0.2, easingStyle, easingDirection), {Offset = Vector2.new(0,0)})
local hoverButtonSize1 = ts:Create(script.Parent.ImageButton, TweenInfo.new(0.2, easingStyle, easingDirection), {Size = StartingSizeimage})
local hoverButtonSize2 = ts:Create(script.Parent.ImageButton, TweenInfo.new(0.2, easingStyle, easingDirection), {Size = endingSizeimage})
local rot = ts:Create(script.Parent.ImageButton, TweenInfo.new(0.2, easingStyle, easingDirection), {Rotation = -10})
local rotstart = ts:Create(script.Parent.ImageButton, TweenInfo.new(0.2, easingStyle, easingDirection), {Rotation = 0})



script.Parent.ImageButton.MouseEnter:Connect(function()
	hoverSound:Play()
	hoverButtonSize2:Play()
	rot:Play()
end)

script.Parent.ImageButton.MouseLeave:Connect(function()
	hoverButtonSize1:Play()
	rotstart:Play()
end)```

first thing i see is this

local endingSizeimage = UDim2.new({0.069, 0},{0.173, 0})
local StartingSizeimage = UDim2.new({0.061, 0},{0.16, 0})

you don’t need brackets when making a new size

local endingSizeimage = UDim2.new(0.069, 0, 0.173, 0)
local StartingSizeimage = UDim2.new(0.061, 0, 0.16, 0)

also you could use .fromScale instead of .new just to shorten it

local endingSizeimage = UDim2.fromScale(0.069, 0.173)
local StartingSizeimage = UDim2.fromScale(0.061, 0.16)

consider making a variable for imagebutton so you aren’t doing script.parent so many times
you could even do the same for tweeninfo

local holder = script.Parent.Holder
local ts = game:GetService("TweenService")
local mainUi = holder["Main pet menu"]
local hoverSound = script.ui_hover_ugd

local endingSizeimage = UDim2.fromScale(0.069, 0.173)
local StartingSizeimage = UDim2.fromScale(0.061, 0.16)

local tInfo = TweenInfo.new(
    0.2, Enum.EasingStyle.Back, Enum.EasingDirection.Out
)

local Button = script.Parent.ImageButton
local Gradient = Button.UIGradient

local hoverButtonGradient = ts:Create(Gradient, tInfo, {Offset = Vector2.new(0,1)})
local hoverButtonGradient2 = ts:Create(Gradient, tInfo, {Offset = Vector2.new(0,0)})

local hoverButtonSize1 = ts:Create(Button, tInfo, {Size = StartingSizeimage})
local hoverButtonSize2 = ts:Create(Button, tInfo, {Size = endingSizeimage})

local rot = ts:Create(Button, tInfo, {Rotation = -10})
local rotstart = ts:Create(Button, tInfo, {Rotation = 0})
-- way shorter and easier to read
1 Like

ye i forgot that thank you man i appicarate it
cool game btw:

1 Like

I completely forgot about this spotify remake
I made it when i was sort of new to scripting

1 Like

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