Hello!
So, today I was making a game with a shop and I was making a shop button. I was making an effect when you hover over it the text size smoothly goes up to 30, then smoothly goes back down to 25 (the starting size). However, the repeat only executes once and ends. This shouldn't happen, of course, and I can't find the source of it. Also, I tried debugging this myself so if you see any bad practices for debugging please point it out to me because this is the debugged version of my script.
local TweenService = game:GetService("TweenService")
local textButton = script.Parent
local buttonBackground = script.Parent.Parent.Frame
local shopEnabled = false
local pressedPosition = {}
pressedPosition.BackgroundColor3 = Color3.new(0.666667, 0.666667, 0.666667)
pressedPosition.Position = UDim2.new(0, 0, 0.465, 0)
local tweenInfo = TweenInfo.new(
0.5,
Enum.EasingStyle.Cubic,
Enum.EasingDirection.InOut,
0,
true,
0
)
local function click()
local tween = TweenService:Create(textButton, tweenInfo, pressedPosition)
tween:Play()
textButton.Sound:Play()
if shopEnabled == false then
script.Parent.Parent.Parent.ShopGui.Enabled = true
shopEnabled = true
elseif shopEnabled == true then
script.Parent.Parent.Parent.ShopGui.Enabled = false
shopEnabled = false
end
end
local function hover()
print("getting ready")
if textButton.TextSize < 30 then
print("ready")
repeat textButton.TextSize = textButton.TextSize + 1 print("playing") wait(0.01) until textButton.MouseLeave or textButton.TextSize == 30
end
end
local function hoverReverse()
print("getting ready")
if textButton.TextSize > 25 then
print("ready")
repeat textButton.TextSize = textButton.TextSize - 1 print("playing") wait(0.01) until textButton.MouseEnter or textButton.TextSize == 25
end
end
textButton.MouseButton1Click:Connect(click)
textButton.MouseEnter:Connect(hover)
textButton.MouseLeave:Connect(hoverReverse)
Location of this script is in a text button inside of a gui with a frame ("background" of button aka 3d effect) and, of course, the gui is inside of starter gui. The click function is an animation for the button when pressed where it clicks down.
Thanks a lot,
Narwhal

6 comments
You set up TweenService earlier in the script, why didnt you use that?
It doesn't change the actual text size so I can't have that as the base of the second tween. If I could, I am pretty sure it'd be more difficult than this.
Not sure what you mean, Tweens can change any numerical value of any instance. Did you try write any code with tweens yet? If so I'd like to see it. Also creating tweens manually gets really really complicated, so I wouldn't do it unless you have a good understanding of interpolation algorithms.
Yes I did, but scrapped it. I get it now though. Thing is it still didn't work for me for some reason. If you would like you can show me how I could approach this.
Could you edit the post and add your attempt at the end, even if it isnt complete? It would help identify what you are doing wrong.
I deleted it though.