Tween working but I can't see it!

Hello! So, I am trying to make a tween that moves a cloned ImageLabel, then destroys and clones + moves again. It’s part of a loading screen.

I want this “cloned ImageLabel” to tween like this:

Problem

So what’s happening is that the tween prints says that it is working, but it doesn’t show it. I can’t see the tween or ImageLabel.

Here is what I see:

Code

local tweenservice = game:GetService("TweenService")
local count = 0

while wait(3) do
	local gui = script.Parent:Clone()
	gui.Name = "Cloned"
	gui.Position = script.Parent.Position
	gui.ZIndex = 5
	
	local goal = {}
	goal.Position = UDim2.new({0.13, 50},{-0.613, 0})
	
	local tweenInfo = TweenInfo.new(3, Enum.EasingStyle.Elastic, Enum.EasingDirection.Out)
	local tween = tweenservice:Create(gui, tweenInfo, goal)
	
	tween:Play()
	gui:Destroy()
	count = count + 1
	print("Played "..count.." times.")
end

Code is inside of the image label. Can anybody help?

It seems to me you’ve cloned the gui but never parented it back into something in PlayerGui so it isn’t appearing. I would set the parent to be same as the original gui’s parent.

Also, the script is a child of the gui so you will also be cloning the script and running it on each subsequent clone which is probably unintended (this can lead to memory leaks or unexpected behavior). I would move the script under the gui’s parent and clone it from there. So for example you should use:
local gui = script.Parent[GuiYouWantToClone]:Clone()
instead and after setting gui properties use:
gui.Parent = script.Parent
or
gui.Parent = [referenceToMainGui]

Lastly, you also want to wait for the tween to finish using the Tween.Completed event before calling Destroy. This would work:
tween.Completed:Wait()

Hope that helps, cheers.

2 Likes

goal:TweenPosition(UDim2.new(0.13, 50, -0.613, 0), Out, Elastic, 3)
I always use this when tweening gui it is much easier to code with this

you used UDim2 with these brackets in them ({}) I never used it like that so I am not sure if it works, you should try without them