Referring to Egomoose’s topic on FPS viewmodel’s, my current aiming code looks like this.
function ToolModule:AimDownSight(AimingBool)
local ViewModel_Tool = self.ViewModel:FindFirstChildWhichIsA("Model")
if ViewModel_Tool then
local Offset = ViewModel_Tool.InvisParts.BodyAttach.CFrame:inverse() * ViewModel_Tool.InvisParts.Aim.CFrame
local joint = self.ViewModel.Torso.Motor6D
local goal = AimingBool and joint.C0 * Offset or CFrame.new()
local LERP_TIME = 0.2
local aimCount = 0
aimCount += 1
local current = aimCount
local current_time = 0
while current == aimCount and current_time < LERP_TIME do
current_time += RunService.RenderStepped:Wait()
joint.C1 = joint.C1:Lerp(goal, math.min(current_time/LERP_TIME,1))
end
end
end
This is the result.
https://gyazo.com/b83e534061e5842e3b5c1e2e1524b2b0
I imagine the problem has to do with Offset, however, I don’t understand why the goal CFrame is incorrect because of it.