Hello, I have been working on an FPS framework but I am having some problems with my walking animation, here is what I mean:
Here is my script:
local plr = game.Players.LocalPlayer
local character = plr.Character or plr.CharacterAdded:Wait()
local humanoid = character:WaitForChild('Humanoid')
local rs = game:GetService('RunService')
local cam = workspace.Camera
local viewModel = game.ReplicatedStorage.Pistol:Clone()
viewModel.Parent = cam
local cf = CFrame.new()
cf = CFrame.new(1.5,-1,1.5)
rs.RenderStepped:Connect(function()
viewModel:SetPrimaryPartCFrame(cam.CFrame * cf)
if humanoid.MoveDirection.Magnitude > 0 then
local Y
local X
local Time = tick()
if math.sin(Time*3)>=0 then
Y = -math.sin(Time * 3)
else
Y = math.sin(Time * 3)
end
if math.cos(Time*4)>=0 then
X = -math.cos(Time * 4)
else
X = math.cos(Time * 4)
end
cf = cf:Lerp(CFrame.new(1.5 + X,-1+Y,1.5),0.1)
else
cf = cf:Lerp(CFrame.new(1.5,-1,1.5),0.1)
end
end)
How can I fix this?
Thank you!