Cframe lookvector issues (or anim issues)

hello, i’ve made a basic sword with some animations and i’ve got an issue to when the player clicks quick enough to where the animations don’t reset to the natural idle animation, the lookvector is causing the player to sort of bounce to the ground and move left or right and not straight when shiftlocked (sorry if i explained it badly)

i’m trying to make it to where the bodyvelocity goes forward and not in another direction, without it being too slow

i’ve tried making waits and it worked, however it doesn’t feel very right and the point was to make the attack anims blend into the next attack anim

this one is when the head is back forwards after the animation is done playing, making the bodyvelocity fixed, but it’s slow and the anim doesn’t blend into the next

this one is when the player clicks quickly, and the animations blend into the next animation but the bodyvelocity is following the torso which isn’t forward like i wanted it, causing it to move my character left, right, and down

i don’t know if it’s an animation or with the script, although to be frank i’m not too happy about the animations

local function swoosh(player)
	local Character = tool.Parent
	
	print("click")
	if attacknumber == 1 and debounce == false then
		debounce = true
			print("no1")
			if Character then
				local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
				if Humanoid then
					local LoadedAnim = nil
					LoadedAnim = Humanoid:LoadAnimation(swing1anim)
					
				if LoadedAnim then
					bodyVelocity.Parent = Character.HumanoidRootPart
					bodyVelocity.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
					bodyVelocity.Velocity = -(Character.Head.CFrame.ZVector * 4)
					
					LoadedAnim:Play()
					swingsound:Play()
					
					damage = true
					trail.Enabled = true
					LoadedAnim.Stopped:Wait()
				
					bodyVelocity.Parent = nil
					damage = false
						attacknumber = 2
					trail.Enabled = false
					print(attacknumber)
					debounce = false
				 
	
									
									
									
									
									
									
	
									
						end
						end
						end
					

thank you!

The velocity is being updated to with respect to the head, which moves during the animation, so depending on when you start the attack, your character might end up moving in a completely different location.

The only useful part you should ever be using when referencing direction is the HumanoidRootPart since it isn’t affected by animations.

bodyVelocity.Velocity = (Character.HumanoidRootPart.CFrame.LookVector * 4)
1 Like

this worked, thank you very much! :+1:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.