Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Tween is stuck at begin playbackstate?

Asked by 3 years ago
Edited 3 years ago

Hi there! So I have a script that manipulates the camera like you are idle in first person. It works all fine.. but when I initiate tween2, the tween is stuck at playbackState.Begin

local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")

local part = scenes.Main

local function getuniquerandom()
    local rng = Random.new(tick())
    local rng2 = Random.new(tick())

    local randomtweentime = rng:NextNumber(1, 2)
    print(randomtweentime)
    local randomtweenangle = rng2:NextNumber(-1, 1)
    print(randomtweenangle)

    tween = TweenService:Create(part,TweenInfo.new(randomtweentime, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,0,true,0),{CFrame = part.CFrame * CFrame.Angles(math.rad(randomtweenangle), math.rad(randomtweenangle), 0)})
    tween2 = TweenService:Create(part,TweenInfo.new(randomtweentime, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut,0,true,0),{CFrame = part.CFrame * CFrame.Angles(math.rad(randomtweenangle), math.rad(randomtweenangle), 0)})

return end



repeat wait() until cam.CameraSubject ~= nil

local plr = game.Players.LocalPlayer
local Character = plr.Character


cam.CameraType = Enum.CameraType.Scriptable

cam.CFrame = scenes.Main.CFrame

getuniquerandom()
tween:Play()

print("playing")

tween.Completed:Connect(function()
    wait(1.1)
    print("newtween")
    getuniquerandom()
    tween2:Play()
end)
tween2.Completed:Connect(function()
    wait(1.1)
    print("newtween")
    getuniquerandom()
    tween:Play()
end)

local conn = RunService.RenderStepped:Connect(function(dt)
    cam.CFrame = scenes.Main.CFrame
    print(tween.PlaybackState)
end)

How does this problem arise and what is the fix?

Thanks in advance

Answer this question