local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local isTweening = false
local UIS = game:GetService("UserInputService")
local tweenService = game:GetService("TweenService")
local ti = TweenInfo.new(
0.5,
Enum.EasingStyle.Cubic
)
UIS.InputBegan:Connect(function(key, isTyping)
if isTweening==false then
if key.KeyCode == Enum.KeyCode.E then
isTweening = true
local t1 = tweenService:Create(humanoid, ti, { CameraOffset = Vector3.new(1.6, 1, 0) })
t1:Play()
t1.Completed:Connect(function()
humanoid.CameraOffset = Vector3.new(1.6, 1, 0)
isTweening = false
end)
end
if key.KeyCode == Enum.KeyCode.Q then
isTweening = true
local t1 = tweenService:Create(humanoid, ti, { CameraOffset = Vector3.new(-1.6, 1, 0) })
t1:Play()
t1.Completed:Connect(function()
humanoid.CameraOffset = Vector3.new(-1.6, 1, 0)
isTweening = false
end)
end
end
end)
UIS.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E or key.KeyCode == Enum.KeyCode.Q and isTweening==true then
isTweening = false
tweenService:Create(humanoid, ti, { CameraOffset = Vector3.new(0, 0, 0) }):Play()
end
end)
Yeah so idk why the camera offset keeps on resetting after the tween completes even though I setted the camera offset manually after the tween completes