Hello DevForum, i am scripting a FPS Framework and ran into an issue with the viewmodel.
I was trying to make a viewmodel walking animation and this happend:
The viewmodel points to the center of the map instead of getting locked to the camera.
Here is the script i used to make the viewmodel walking animation:
function renderloop()
if char.Humanoid.MoveDirection.Magnitude > 0 then
local CurrentTime = tick()
local x = math.cos(CurrentTime*10)*.6;
local y = math.abs(math.sin(CurrentTime*10))*.6;
local Velocity = (char.HumanoidRootPart.Velocity.Magnitude)
local VelocityClamped = math.clamp(Velocity * .25, 0, 10)
viewmodel.HumanoidRootPart.CFrame = viewmodel.HumanoidRootPart.CFrame:Lerp( CFrame.new(x * .1 * VelocityClamped, y * .35 * (VelocityClamped),0) * CFrame.Angles(y * .05 * (VelocityClamped), y * .05 * (VelocityClamped), 0), 0.12)
--Got This from the devforum
end
end
runservice.RenderStepped:Connect(function()
renderloop()
end)
Help would be appreciated.
Thanks!