I have a menu gui with a camera that tweens around the map, and when i try to cancel the tween after they hit the play button. It only works if you hadn’t reached the second tween yet. Heres my script an example.
local tweenInfo = TweenInfo.new(
65, -- Speed
Enum.EasingStyle.Linear, -- Easing Style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Repeat Count
false, -- Reverse
0 -- Delay Time
)
local function tweenCycle(tween1, tween2, tween3, tween4, endTween)
tween1:Play()
tween1.Completed:Wait() -- I'm thinking its something to do with the wait here? Its waiting for it to complete before it can cancel?
tween2:Play()
tween2.Completed:Wait()
tween3:Play()
tween3.Completed:Wait()
tween4:Play()
tween4.Completed:Wait()
endTween:Play()
end
local tween1 = tweenService:Create(camera, tweenInfo, {CFrame = cameras["2"].CFrame})
local tween2 = tweenService:Create(camera, tweenInfo, {CFrame = cameras["3"].CFrame})
local tween3 = tweenService:Create(camera, tweenInfo, {CFrame = cameras["4"].CFrame})
local tween4 = tweenService:Create(camera, tweenInfo, {CFrame = cameras["5"].CFrame})
local endTween = tweenService:Create(camera, tweenInfo, {CFrame = cameras["1"].CFrame})
button.MouseButton1Click:Connect(function()
tween1:Cancel() -- It works if im on tween 1 but after that nothing gets cancelled and the camera starts moving to where the part is, then back to the player
tween2:Cancel() -- I even tried pausing the tweens before cancelling, doesnt work
tween3:Cancel()
tween4:Cancel()
endTween:Cancel()
end)
Once the player spawns in the camera starts moving out of the spawn area to the tween part, then goes back to the player straight after it reaches the tween part. Im thinking its because of the tween.Completed:Wait()
Heres a video if you dont understand what I mean.
robloxapp-20210119-1743323.wmv (1.3 MB)