TweenSize issue

Currently i’m very new to scripting, basically im trying to add a beating heart GUI to my own game and using tweensize to animate the beating. But currently when I slow it down to normalize the heart beat it becomes inconsistent and breaks usually or only does the first and last lines sizing commands only.

Heres what I’m talking about
robloxapp-20200608-0352320.wmv (44.4 KB)
At the beginning it trys to beat but then stops.

I believe that its probably because it overlaps the next sizing instruction and breaks the code that way, or when it does overlap it breaks the second line only using the third or first.
and heres the code.

while true do

local object = script.Parent

object.AnchorPoint = Vector2.new(0.5, 0.5)

object.Position = UDim2.new(0.5, 0, 0.5, 0)

wait(0.1)

object:TweenSize(UDim2.new(0, 83, 0, 63), 0, 0, 0.1)

wait(0.25)

object:TweenSize(UDim2.new(0, 105, 0, 57), 0, 0, 0.25)

wait(0.1)

object:TweenSize(UDim2.new(0, 124, 0, 71), 0, 0, 0.1)

end

If anyone knows how to fix this then please let me know because i’m very inexperienced with scripting and it would be appreciated as this is my first time posting onto the scripting assist forum.

Firstly, you have the Wait()'s in the wrong position.

while true do

local object = script.Parent

object.AnchorPoint = Vector2.new(0.5, 0.5)

object.Position = UDim2.new(0.5, 0, 0.5, 0)

object:TweenSize(UDim2.new(0, 83, 0, 63), 0, 0, 0.1)
wait(0.1)
object:TweenSize(UDim2.new(0, 105, 0, 57), 0, 0, 0.25)
wait(0.25)
object:TweenSize(UDim2.new(0, 124, 0, 71), 0, 0, 0.1)
wait(0.1)
end

Secondly, if you want to alternate the heartbeat, you will need to store the wait() time’s in a variable and then change them when you’re altering them.

local Relax = 0.25
local Beat = 0.1

while true do

local object = script.Parent

object.AnchorPoint = Vector2.new(0.5, 0.5)

object.Position = UDim2.new(0.5, 0, 0.5, 0)

object:TweenSize(UDim2.new(0, 83, 0, 63), 0, 0, Beat)
wait(Beat)
object:TweenSize(UDim2.new(0, 105, 0, 57), 0, 0, Relax)
wait(Relax)
object:TweenSize(UDim2.new(0, 124, 0, 71), 0, 0, Beat)
wait(Beat)
end

Lastly, to tidy your script, you can remove two lines:

local Relax = 0.25
local Beat = 0.1

while true do

local object = script.Parent

object.AnchorPoint = Vector2.new(0.5, 0.5)

object.Position = UDim2.new(0.5, 0, 0.5, 0)

object:TweenSize(UDim2.new(0, 83, 0, 63), 0, 0, Beat)
wait(Beat)
object:TweenSize(UDim2.new(0, 105, 0, 57), 0, 0, Relax)
wait(Relax)
end
1 Like