Hi I'm trying to create a simple camera "tween" and after that tween the camera will stay fixed until the dialog ends Video
The issue that I have is that when I first call my coroutine to resume
it will run as expected but after calling it again the status will return dead
.
here is the code
local CanLoopCam = false local TweenCam = coroutine.create(function() CanLoopCam = false if not CanLoopCam then for i = 0,0.5,.01 do Camara.CFrame = Camara.CFrame:Lerp(PP.Parent.Parent.o.CFrame, i) task.wait() end CanLoopCam = true while CanLoopCam do task.wait() Camara.CFrame = PP.Parent.Parent.o.CFrame end end end) function CANTtalk() CanLoopCam = false canTalk = true Camara.CameraType = Enum.CameraType.Custom MainFrame.Dialogo.Text = " " humanoid.WalkSpeed = 20 end function CANtalk() print(coroutine.status(TweenCam)) canTalk = false Camara.CameraType = Enum.CameraType.Scriptable humanoid.WalkSpeed = 0 MainFrame.Titulo.Text = npc.Name coroutine.resume(TweenCam) end
I tried yielding but it stops everything. Video
function CANTtalk() CanLoopCam = false canTalk = true Camara.CameraType = Enum.CameraType.Custom MainFrame.Dialogo.Text = " " humanoid.WalkSpeed = 20 coroutine.yield(TweenCam) end
Help is appreciated, I tried a lot of stuff but I'm still learning how to script
Kind of a hacky solution but it works. when you call CANTtalk() it closes the current TweenCam and when you call CANtalk() it remakes TweenCam and resumes it. Doesnt return dead anymore since its an entirely new TweenCam
local CanLoopCam = false local TweenCam = coroutine.create(function() CanLoopCam = false if not CanLoopCam then for i = 0,0.5,.01 do Camara.CFrame = Camara.CFrame:Lerp(PP.Parent.Parent.o.CFrame, i) task.wait() end CanLoopCam = true while CanLoopCam do task.wait() Camara.CFrame = PP.Parent.Parent.o.CFrame end end end) function CANTtalk() coroutine.close(TweenCam) CanLoopCam = false canTalk = true Camara.CameraType = Enum.CameraType.Custom MainFrame.Dialogo.Text = " " humanoid.WalkSpeed = 20 end function CANtalk() canTalk = false Camara.CameraType = Enum.CameraType.Scriptable humanoid.WalkSpeed = 0 MainFrame.Titulo.Text = npc.Name coroutine.resume(TweenCam) TweenCam = coroutine.create(function() CanLoopCam = false if not CanLoopCam then for i = 0,0.5,.01 do Camara.CFrame = Camara.CFrame:Lerp(PP.Parent.Parent.o.CFrame, i) task.wait() end CanLoopCam = true while CanLoopCam do task.wait() Camara.CFrame = PP.Parent.Parent.o.CFrame end end end) print(coroutine.status(TweenCam)) end