Skip to content
This repository was archived by the owner on Nov 10, 2018. It is now read-only.
This repository was archived by the owner on Nov 10, 2018. It is now read-only.

Tween function resumes wrong thread #239

@Anaminus

Description

@Anaminus

The following script demonstrates the TweenPosition function with a callback specified. The tween is set to take 2 seconds long (tweenTime). TweenPosition spawns a separate thread, so the call returns immediately. Right after the call, the current thread is yielded for 6 seconds (waitTime).

local screen = Instance.new('ScreenGui',Game.StarterGui)
local frame = Instance.new('Frame',screen)
frame.Size = UDim2.new(0,100,0,100)
frame.Position = UDim2.new(0,100,0,100)

wait(2)

----------------
----------------

local tweenTime = 2
local tweenStart = tick()
local function callback()
    print('Tween time:',tick()-tweenStart)
end

print('Start tween')
frame:TweenPosition(UDim2.new(0,400,0,100),'Out','Quad',tweenTime,false,callback)

----------------
----------------

local waitTime = 6
local waitStart = tick()

print('Start wait')
wait(waitTime)

print('Wait time:',tick()-waitStart)

The results are the following:

  • The call to wait only yields for 2 seconds (tweenTime), instead of the expected 6.
  • After 6 seconds (waitTime), an attempt to call a nil value error is thrown.
  • The callback function is never actually called.

This behavior only occurs when a callback function is specified, and the current thread is yielded longer than the tween (waitTime > tweenTime).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions