Hello, This script uses tweens to zoom in and out but the camera doesn’t zoom in or out when I release the button before the tween is finished. I want the camera to zoom out even if the tween is not finished.
--[local script
script.Parent.Handle.CanTouch = false
local remoteEvent = game.ReplicatedStorage.Throw
local tool = script.Parent
local cam = workspace.CurrentCamera
local maxZoom = 25
local minZoom = 75
local plrStrength = game.Players.LocalPlayer.IMFOLDER.PlayerStrength.Value
local ogplrStrength = plrStrength -- Does not change because it is the strength that zooming out reverts to
local uis = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local plrPos = player.Character.HumanoidRootPart.CFrame
local mousePos = player:GetMouse().Hit.p
local throwAnim = script:WaitForChild("Throwing")
local thowingAnim = player.Character.Humanoid:LoadAnimation(throwAnim)
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://15540379440"
local animationTrack = player.Character.Humanoid:LoadAnimation(animation)
-- TOOL IS USED HERE
tool.Activated:Connect(function()
mousePos = player:GetMouse().Hit.p
remoteEvent:FireServer(mousePos, plrStrength)
game.Players.LocalPlayer.IMFOLDER.hasBall.Value = false
print(game.Players.LocalPlayer.IMFOLDER.hasBall.Value)
tool.Parent = game.ReplicatedStorage
animationTrack:Stop()
repeat wait()
cam.FieldOfView += 1
until cam.FieldOfView >= minZoom
end)
--TOOL IS GRABBED HERE
tool.Equipped:Connect(function()
local pressed = false
game.Players.LocalPlayer.IMFOLDER.hasBall.Value = true
print(game.Players.LocalPlayer.IMFOLDER.hasBall.Value)
end)
--ZOOMING IS STARTED
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Quad,
Enum.EasingDirection.InOut,
0,
false
)
local tween = TweenService:Create(cam, tweenInfo, {FieldOfView = maxZoom})
local tween2 = TweenService:Create(cam, tweenInfo, {FieldOfView = minZoom})
local userInputService = game:GetService("UserInputService")
userInputService.InputBegan:Connect(function(input, isTyping)
if not isTyping then
if input.UserInputType== Enum.UserInputType.MouseButton2 then
animationTrack:Play()
tween2:Cancel()
tween:Play()
plrStrength += 2
task.wait(.1)
end
end
end)
--ZOOMING IS STOPPED
userInputService.InputEnded:Connect(function(input, isTyping)
if not isTyping then
if input.UserInputType == Enum.UserInputType.MouseButton2 then
animationTrack:Stop()
tween:Cancel()
tween2:Play()
plrStrength = ogplrStrength
task.wait(.1)
end
end
end)