game:GetService("RunService").RenderStepped:Connect(function(deltaTime)
-- Get mouse position in the viewport
local mouseDelta = game:GetService("UserInputService"):GetMouseDelta()
script.Parent.Viewmodel.PrimaryPart = script.Parent.Viewmodel.Torso
-- Apply a small sway based on mouse movement
swayOffset = swayOffset:Lerp(Vector3.new(-mouseDelta.X * swayAmount, -mouseDelta.Y * swayAmount, 0), deltaTime * swaySpeed)
-- Detect walking by checking the humanoid's velocity
local velocity = humanoid.MoveDirection.Magnitude
local velocity2 = Humanoid.Parent.HumanoidRootPart.Velocity.Magnitude / 2.3333
local velocity3 = math.clamp(Humanoid.Parent.HumanoidRootPart.Velocity.Magnitude / 650,0.001,0.03)
if velocity > 0 then
-- Create a simple walking sway effect using sin to simulate walking bobbing motion
walkCycle = walkCycle + deltaTime * velocity2
local walkSwayX = math.sin(walkCycle) * walkSwayAmount / 5.333333
local walkSwayY = math.abs(math.cos(walkCycle)) * velocity3 / 5.3333 -- Use abs to simulate vertical walking bounce
swayOffset = swayOffset + Vector3.new(walkSwayX, walkSwayY, 0)
end
-- Apply sway to the CFrame
local swayCFrame = Camera.CFrame * CFrame.new(0.33/4,-0.583/4,-0.11/4) * CFrame.new(swayOffset)
-- Smoothly move the viewmodel to the desired position
VM_Character:SetPrimaryPartCFrame(swayCFrame)
-- Disable collisions
VM_Character.Torso.CanCollide = false
end)
The arm somehow gets like shorter and compressed??? I am sure it has to with the script and the torso.
Check the ViewModel size everytime you re-equip, it might be changing with the CFrame.
the scale is set to 0.25 to prevent the unusual viewmodel clipping
However its no difference depending how big on the size was, Do you think putting it in a seperate local script work?
Yes, try that, the issue might be also related to the calculations.
Nevermind i fixed it! Do not set the animations as the same Animationpriority!!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.