Hey. I’m having problems with tweening the camera along with the HumanoidRootPart.
Heres a gif of whats happening > https://gyazo.com/5d96df4d61d32d37c46976d5b6b4ea83
I’ve tried stopping the tweening for HumanoidRootPart’s rotation – and it worked. I’m wondering if there is a way to tween it and for it to stop tweening.
Heres a block of my code.
function RenderStepped()
if equip == true
then
userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
local humanoidRootPart = player.Character.HumanoidRootPart
local CFrameOffset
local camSubject = humanoidRootPart
local camPos = CFrame.new(humanoidRootPart.Position)
* CFrame.Angles(0, math.rad(yaw), 0)
* CFrame.Angles(math.rad(pitch), 0, 0)
* CFrame.new(0, 3, 0) * CFrame.new(0,0, camDist)
local camFocus = camSubject and camSubject.Position
local ray = Ray.new(camPos.p, camera.CFrame.LookVector * camDist)
local ignoreList = {player.Character}
local hit,pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignoreList)
if hit then
dist = camDist - (pos - ray.Origin).Magnitude - 2 or camDist
else
dist = camDist
end
if aimedIn == false or reloading == true then
mouse.Icon = none
userInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
player.Character.Humanoid.WalkSpeed = 13
local tween = tweenService:Create(camera, TweenInfo.new(0.05, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
CFrame = CFrame.new(humanoidRootPart.Position)
* CFrame.Angles(0, math.rad(yaw), 0) * CFrame.Angles(0, humanoidRootPart.CFrame.LookVector.Y, 0)
* CFrame.Angles(math.rad(pitch), 0, 0)
* CFrame.new(0, 3, 0) * CFrame.new(0,0, dist)
}
)
tween:Play()
else
player.Character.Humanoid.WalkSpeed = 8
humanoidRootPart.CFrame = CFrame.new(humanoidRootPart.Position) * CFrame.Angles(0, math.rad(yaw), 0)
mouse.Icon = dot
local tween = tweenService:Create(camera, TweenInfo.new(0.05, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut), {
CFrame = humanoidRootPart.CFrame * CFrame.new(2, 2, 1.5) * CFrame.Angles(math.rad(pitch), 0, 0)
}
)
tween:Play()
end
end
end