BodyForce not working after playing animation

  1. What do you want to achieve?
    I want to make a dash animation that works with bodyforce.

  2. What is the issue?
    So basically it works, but if I run another animation it breaks the bodyforce of the dash animation.

  3. What solutions have you tried so far?
    I tried looking on the internet but didnt find anything usefull

This right here is the dash script

eevent.OnServerEvent:Connect(function(plr)
	if otherdeb == false then
		eevent:FireClient(plr)
		local canslide = true
		print("testANIM1")
		otherdeb = true
		local hum = plr.Character:WaitForChild("Humanoid")
		local animator = hum:WaitForChild("Animator")
		local animpaly = animator:LoadAnimation(script.ROLL)
		if canslide == true then
			canslide = false
			animpaly:Play()
		
			local slide = Instance.new("BodyVelocity")
			slide.MaxForce = Vector3.new(1,0,1) * 30000
		slide.Parent = plr.Character.HumanoidRootPart
		slide.Velocity = plr.Character.HumanoidRootPart.CFrame.lookVector * 100
		
		
			for count = 1, 4 do
				print("velocity go br")
			wait(0.1)
			slide.Velocity *= 0.3
		end
		animpaly:Stop()
			slide:Destroy()
			wait(1)
		canslide = true
		end
		
		
		
		
		
		
		
		
		
		wait(1)
		otherdeb = false
	end
end)

And this right here is the punch script (modulescript)

local fruit = {}

local rp = game:GetService("ReplicatedStorage")
local VFX = rp:WaitForChild("VFX")



function fruit.Createhitbox(player, character, humrp)
	
	print("test")
	local Hitbox = script.Hitbox.Part:Clone()
	Hitbox.Parent = workspace
	Hitbox.CFrame = humrp.CFrame * CFrame.new(0,0,-2)
	
	local weld = Instance.new("ManualWeld")
	weld.Part0 = Hitbox
	weld.Part1 = humrp
	weld.C0 = weld.part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
	weld.Parent = weld.Part0
	print("test")
	
	local connection
	
	connection = Hitbox.Touched:Connect(function()
		
	end)
	
	local results = Hitbox:GetTouchingParts()
	coroutine.wrap(function()
		for i, obj in pairs(results) do
			if not results[i]:IsDescendantOf(character)then
				local ehumanoid = results[i].Parent:FindFirstChild("Humanoid")
				local ehumrp = results[i].Parent:FindFirstChild("HumanoidRootPart")
				if ehumanoid and ehumanoid.Health > 0 then
					Hitbox:Destroy()
					
					
					if connection then
						connection:Disconnect()
					end
					
					ehumanoid:TakeDamage(10)
					
					coroutine.wrap(function()
						print("CallVFX")
						for _, plr in pairs(game.Players:GetChildren()) do
							VFX:FireClient(plr,"CombatVFX","vfx",ehumrp)
						end
					end)()
					break
				end
			end
		end
	end)()
	
end


return fruit

And this the punch script(script)

local module = require(game.ServerScriptService.ModuleScript)
local event = game.ReplicatedStorage.Clicked
local debounce = false
local eevent = game.ReplicatedStorage.ROll
local otherdeb = false
event.OnServerEvent:Connect(function(player)
	event:FireClient(player,debounce)
	if debounce == false then
		
		
		local char = player.Character
	local hum = char:WaitForChild("Humanoid")
	local animator = hum:WaitForChild("Animator")
	local anim = animator:LoadAnimation(script.Animation)
	anim:Play()
	anim:GetMarkerReachedSignal("Hitbox"):Connect(function()
		module.Createhitbox(player,char,char.HumanoidRootPart)
		print("test")
		end)
		debounce = true
		wait(1.2)
		debounce = false
	end
	
end)

Sorry for writing so much I hope someone can help!

Did I really just record with my mic on :flushed:

A debounce should do the trick, i.e; prevent stacking of animations.

1 Like

I did that already but no worries, I fixed it. I forgot to destroy my hitbox after punching.