I’m having an issue where the game ignores my code for tweening a hud element. No error is given and it just skips the tween entirely.
local CS = game:GetService('CollectionService')
local RS = game:GetService('ReplicatedStorage')
local contentProvider = game:GetService('ContentProvider')
local tweenServive = game:GetService('TweenService')
local player = game:GetService('Players').LocalPlayer
repeat task.wait() until game:IsLoaded()
local gui = player.PlayerGui
script.loadingScreen.Parent = gui
for i, assetLoading in game:GetDescendants() do
contentProvider:PreloadAsync({assetLoading})
end
for i, object in pairs(CS:GetTagged('Invis')) do
object.Transparency = 1
end
local tweenScreenUp = tweenServive:Create(gui.loadingScreen.Black, TweenInfo.new(2), { Position = UDim2.new(-1, 0, 0, 0) } )
tweenScreenUp:Play()
repeat task.wait() until tweenScreenUp.Completed --replacing this with 'task.wait(2)' doesnt fix anything
gui.loadingScreen:Destroy()
Different code that has the same issue, the tween seems to end within a frame.
local text = script.Parent
local tweenServive = game:GetService('TweenService')
local tweentext = tweenServive:Create(text, TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.2,0,0.2,0)} )
local tweentextreverse = tweenServive:Create(text, TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut), {Size = UDim2.new(0.1,0,0.2,0)} )
while true do
tweentext:Play()
repeat task.wait() until tweentext.Completed
tweentextreverse:Play()
repeat task.wait() until tweentextreverse.Completed
end
This script DOES work, but i dont know what makes it different from the other two.
local spinner = script.Parent
local tweenServive = game:GetService('TweenService')
local startatfive = 5
while true do
local rotateBy = spinner.Rotation + startatfive
local tweenSpin = tweenServive:Create(spinner, TweenInfo.new(1), {Rotation = rotateBy} )
tweenSpin:Play()
repeat task.wait() until tweenSpin.Completed
startatfive += 0.1
end
Some things to note, because your current solution is not really correct.
Tween.Completed is an event, not a bool value indicating whether it’s finished or not, meaning that you can use :Connect() or :Wait() for specific things for its completion.
Also, because conditions always run whenever the condition is either true or something that isn’t false or nil, your repeat task.wait() until YourTweenObject.Completed will complete because its like saying repeat until tween.Completed exists or is true (which it does since it is an event of tween objects and isnt nil or false) .
Also: repeat task.wait() until tweenWhatever.Completed == true will never end since .Completed is an Event, not a bool value, it will just yield forever.
You can just use tweenWhatever.Completed:Wait(), no need to use repeat-untils