After doing some research, I have a feeling that it would be something with the .Completed event, but I can’t figure out how I would implement that into my game. This is the code that is causing the problem.
I have a feeling it would be something to do with this line, I did try simply waiting 6 seconds and then removing it (Which is what I want to happen to the textLabel when the tween is complete) but adding the 6 second timer just messed with all other parts of my code.
Completed is for Tween objects created by TweenService, which the GuiObject tween methods do not create. Here, you’d have to use the callback function which is the last parameter in a tween call.
It’d probably be better off if you used TweenService anyway over these methods considering it effectively (but not officially) supersedes all built-in tween methods, makes your tweening calls more consistent across code and provides a better API to work with.
Okay, I have my fixed answer here. The problem was that I needed to access “TweenService” in order to access the event of ‘Completed’, so I had to change around a few parts of my code. Below, I have my updated code that works, this will, when the GUI has finished tweening, will delete the TextLabel.
local TweenService = game:GetService("TweenService") -- had to use TweenService to access the event of 'Completed'
local WordLabel = script.Parent
local PositionLabel --Defined earlier on
local TweenInfoLabel = TweenInfo.new(3) -- '3' defines the amount of time that the tween takes place in
local NewTweenPosition = {} -- has to be a table
local NewTweenPosition = UDim2.new(PositionLabel, 0, -0.5, 0) --position I want the GUI to tween to
local tweenLabel = TweenService:Create(WordLabel, tweenInfoLabel, NewTweenPosition) -- creating the tween with all parameters
tweenLabel.Completed:Connect(function()
WordLabel:Remove() -- removes the label when the tween has completed
end)
TweenLabel:Play() -- plays the tween
I have also added comments onto the sections that I was mainly confused on, which may lead to someone else in the future also being confused.