hello today I created an animation where the player makes a frontflip to avoid things and therefore I made a script to move the player but the player goes to one side and does not follow the player's view here the code
local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
local pos = player.Character.HumanoidRootPart
local cam = workspace.CurrentCamera
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=4582289516"
mouse.KeyDown:connect(function(key)
if key == "z" then
local playAnim = humanoid:LoadAnimation(anim)
playAnim:Play()
local AnimationTracks = humanoid:GetPlayingAnimationTracks()
for i = 1,100
pos.CFrame = pos.CFrame + Vector3.new(0,0,0.1)
wait(0.01)
end
end
end)
help

2 comments
You should use body velocities instead, it’s way easier
try doing pos.CFrame = pos.CFrame + cam.CFrame.LookVector*Vector3.new(0.1, 0, 0.1)