#The script continuo before the tween are done...

3 messages · Page 1 of 1 (latest)

plucky jetty
#

I got this script when i'm moving a objekt from one to another and then delete the part. Can anyone tell how I tell the script to run TweenService to the end before continuo the script? Script:

local meteor = game.Workspace.MeteorStarter
repeat
if script.Parent.Parent.Name~= "folder" then
if meteor.Value == 1 then
wait(4.875)
script.Parent.Position = Vector3.new(math.random(-15,15),30,math.random(-15,15))
script.Parent.Position = script.Parent.Position + script.Parent.Parent["Meteor warning"].Position
local TweenService = game:GetService("TweenService")
local End = script.Parent.Parent["Meteor warning"]

        local PartToMove = script.Parent
        local TweenInformation = TweenInfo.new(
            0.125, -- Time
            Enum.EasingStyle.Linear, -- EasingStyle
            Enum.EasingDirection.In, -- Easing Direction
            0, -- Repeat Count
            false, -- Reverses to initial position? (true/false)
            1 -- Delay between each tween.
        )

        local EndProperties = {
            Position = End.Position    
        }

        local TweenToPlay = TweenService:Create(PartToMove,TweenInformation,EndProperties)

        TweenToPlay:Play()
        wait(0.5)
        script.Parent.Transparency = 1
        script.Parent.ParticleEmitter2.Enabled = false
    end
end
wait(.1)

until false

lime sparrow
#

To make the script wait for the Tween to finish before continuing, you can use the Tween.Completed:Wait() method. This method will pause the script until the Tween has completed.

#

Example:

 local TweenToPlay = TweenService:Create(PartToMove,TweenInformation,EndProperties)

TweenToPlay:Play()
TweenToPlay:Wait()  -- Wait for the Tween to finish before continuing
script.Parent.Transparency = 1
script.Parent.ParticleEmitter2.Enabled = false