So I am trying to use body position to move the character when performing an attack. It works completely fine and expected when it is standing still, but when I am moving, it becomes weird.
A video demonstrating the problem
The code
server script
local bp = Instance.new("BodyPosition")
bp.Position = (char.PrimaryPart.CFrame*CFrame.new(0,0,-2)).p
bp.P = 1000
bp.MaxForce = Vector3.new(99999,99999,99999)
bp.D = 10
bp.Parent = char.PrimaryPart
game.Debris:AddItem(bp,.6)
local script
Tool.Activated:Connect(function()
if debounce == false then
debounce = true
if tick() - lasthit < 1.5 then
combo += 1
if combo == #abc + 1 then
combo = 1
end
lasthit = tick()
else
lasthit = tick()
combo = 1
end
print(combo)
script.Attack.AnimationId = abc[combo]
local anim = animator:LoadAnimation(script.Attack)
humanoid.WalkSpeed = 0
anim:Play()
remote:FireServer("M1",nil)
hitbox:HitStart()
wait(.5)
hitbox:HitStop()
wait(cd)
debounce = false
wait(.5)
humanoid.WalkSpeed = 16
end
end)
Any help would be appreciated