How can I make a player get pushed backwards with bodyvelocity depending on their position

Im making a fighting game, and i want the player to get pushed backwards for a certain thing.

I use bodyvelocity and the code goes like this:

function createForce()
    local BV = Instance.new("BodyVelocity")
    BV.Velocity = Vector3.new(8, 0, 8)
    BV.Parent = script.Parent.HumanoidRootPart

    game.Debris:AddItem(BV, 0.3)
end

The issue with this is that its not pushed backwards, its just pushed sideways or front and sometimes backwards.

How can I make it that it detects the players position and change the velocity so it can push the player backwards from that position

function createForce()
	local Root = script.Parent.HumanoidRootPart
	
	local BV = Instance.new("BodyVelocity")
	BV.Velocity = Root.CFrame.LookVector * -8
	BV.Parent = Root

	game.Debris:AddItem(BV, 0.3)
end

Can I ask, how about making the player’s Y-axis go down aswell like down force

function createForce()
	local Root = script.Parent.HumanoidRootPart
	
	local BV = Instance.new("BodyVelocity")
	BV.Velocity = (Root.CFrame.LookVector * -8) + Vector3.new(0, -8, 0)
	BV.Parent = Root

	game.Debris:AddItem(BV, 0.3)
end
2 Likes

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