Would there be a way to fix that? Also, I’m not sure if I need to change
The tween doesn’t seem to be cancelling.
There aren’t any errors.
Would there be a way to fix that? Also, I’m not sure if I need to change
The tween doesn’t seem to be cancelling.
There aren’t any errors.
Can you try adding a print right under the forcestop == false in the TweenFunction, and another print right under the tween:Cancel()? Then test play and click the button during the first tweening action. Then tell me which ones printed after the four tweens.
The tween was cancelled, but it keeps going?
I added print("Tween Cancelled.")
After the forcestop, I also added a print statement, but nothing runs.
I have to go, I’ll be back in an hour, so I apologize if I have a really late response.
I don’t understand why you need the code
Hello, how are you doing?
Try doing this code, i’ve changed the position of the local player and changed the character variable:
local TweenService = game:GetService("TweenService")
local cams = game.Workspace.Cameras
local done = false
local camera = game.Workspace.Camera
local sceneTime = 20
local tween = nil
local forcestop = false
local tweeninfo = TweenInfo.new(
sceneTime,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
true,
0
)
local player = game.Players.LocalPlayer
function TweenFunction(camera1, camera2, ending)
if forcestop == false then
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = camera1.CFrame
tween = TweenService:Create(camera, tweeninfo, {CFrame = camera2.CFrame})
tween:Play()
tween.Completed:Wait()
if ending and forcestop == false then
camera.CameraType = Enum.CameraType.Custom
local character = player.Character
if character then
camera.CameraSubject = character
end
end
end
end
script.Parent.MouseButton1Click:Connect(function()
if tween then
tween:Cancel()
end
camera.CameraType = Enum.CameraType.Custom
local character = player.Character
if character then
camera.CameraSubject = character
end
script.Parent.Parent.Parent.Enabled = false
forcestop = true
end)
TweenFunction(cams.Camera1, cams.Camera2, false)
--wait(20)
TweenFunction(cams.Camera3, cams.Camera4, false)
--wait(20)
TweenFunction(cams.Camera5, cams.Camera6, false)
--wait(20)
TweenFunction(cams.Camera7, cams.Camera8, false)
--wait(20)
TweenFunction(cams.Camera9, cams.Camera10, true)
@DargoA 's code, but modified a little bit.
It doesn’t seem to do anything different, could you explain the changes?
In his code, the local player variable was below the TweenFunction function. i’ve moved it above it and changed this
with this
Just edited my code, i changed this line (inside the mousebutton1click function)
to the same thing as well.
Unfortunately that didn’t fix the problem of the tween running after pressing the button.
It seems to cancel the 1st tween, but the 2nd tween runs after the tween cancel. Do you know how to fix this?
I see, pretty strange of what is happening.
You’re code doesn’t seem to have any errors or anything “wrong”.
I’m aware it’s because of the wait. Try this:
Change this line
with this:
if not forcestop then
TweenFunction(cams.Camera1, cams.Camera2, false)
end
--wait(20)
if not forcestop then
TweenFunction(cams.Camera3, cams.Camera4, false)
end
--wait(20)
if not forcestop then
TweenFunction(cams.Camera5, cams.Camera6, false)
end
--wait(20)
if not forcestop then
TweenFunction(cams.Camera7, cams.Camera8, false)
end
--wait(20)
if not forcestop then
TweenFunction(cams.Camera9, cams.Camera10, true)
end
It’s making the cameras run weirdly, let me try it again.
Still the same issue occuring.
So even after cancelling, the whole thing still happens?
Do you want a video of what’s happening?
Yeah, that’d make it much easier to understand.
I’ll have to go AFK right now, i’ll try to help you as soon as i’m back.
Alright, here’s the video:
robloxapp-20210325-1325514.wmv (1.2 MB)
On button click it does set it to the player, but I deleted the player on accident.
I decided (desperately) to spam a bunch (a bunch being the amount of tweens) of tween:Cancel()
and it seems to have solved the problem.
However, I’m not sure it’s a very good way to do it…
local TweenService = game:GetService("TweenService")
local cams = game.Workspace.Cameras
local done = false
local camera = game.Workspace.Camera
local sceneTime = 20
local tween = nil
local forcestop = false
local tweeninfo = TweenInfo.new(
sceneTime,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
true,
0
)
local player = game.Players.LocalPlayer
function TweenFunction(camera1, camera2, ending)
if forcestop == false then
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = camera1.CFrame
tween = TweenService:Create(camera, tweeninfo, {CFrame = camera2.CFrame})
tween:Play()
tween.Completed:Wait()
if ending and forcestop == false then
camera.CameraType = Enum.CameraType.Custom
local character = player.Character
if character then
camera.CameraSubject = character
end
end
end
end
script.Parent.MouseButton1Click:Connect(function()
if tween then
tween:Cancel()
tween:Cancel()
tween:Cancel()
tween:Cancel()
tween:Cancel()
end
camera.CameraType = Enum.CameraType.Custom
local character = workspace:FindFirstChild(player.Name)
if character then
camera.CameraSubject = character
end
script.Parent.Parent.Parent.Enabled = false
forcestop = true
end)
if not forcestop then
TweenFunction(cams.Camera1, cams.Camera2, false)
end
--wait(20)
if not forcestop then
TweenFunction(cams.Camera3, cams.Camera4, false)
end
--wait(20)
if not forcestop then
TweenFunction(cams.Camera5, cams.Camera6, false)
end
--wait(20)
if not forcestop then
TweenFunction(cams.Camera7, cams.Camera8, false)
end
--wait(20)
if not forcestop then
TweenFunction(cams.Camera9, cams.Camera10, true)
end