So, I’m using the Roblox gun system, and I was making aiming, but I came across an issue. I want the view model to be at the point that you are aiming down the sights, and I did that, but I want to tween it.
code:
for _, instance in self.toolInstances do
instance.LocalTransparencyModifier = 1
end
-- View model bobbing animation
local moveSpeed = (self.handle.AssemblyLinearVelocity * Vector3.new(1, 0, 1)).Magnitude
local bobbingSpeed = moveSpeed * Constants.VIEW_MODEL_BOBBING_SPEED
local bobbing = math.min(bobbingSpeed, 1)
self.stride = (self.stride + bobbingSpeed * deltaTime) % (math.pi * 2)
self.bobbing = lerp(self.bobbing, bobbing, math.min(deltaTime * Constants.VIEW_MODEL_BOBBING_TRANSITION_SPEED, 1))
local x = math.sin(self.stride)
local y = math.sin(self.stride * 2)
local bobbingOffset = Vector3.new(x, y, 0) * Constants.VIEW_MODEL_BOBBING_AMOUNT * self.bobbing
local bobbingCFrame = CFrame.new(bobbingOffset)
local CF = Constants.VIEW_MODEL_OFFSET
if self.blaster:GetAttribute("_Aiming") then
print(self.blaster:GetAttribute("_Aiming"))
CF = CFrame.new(0,-1.25,0)
end
self.model:PivotTo(camera.CFrame * CF * bobbingCFrame)