I want the enemies to get push back when player dash in the air and hit the enemy but when i try it nothing happen
here is the script, im very new to scripting so the script might look very bad:
local UIS = game:GetService("UserInputService")
local TagService = game:GetService("CollectionService")
local Character = game.Players.LocalPlayer.Character
local Humanoid = script.Parent.Parent.Humanoid
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RaycastHitbox = require(ReplicatedStorage.RaycastHitboxV4)
local newHitbox = RaycastHitbox.new(script.Parent.Parent:WaitForChild("HumanoidRootPart"))
local DashParticle = script.Parent.Parent:WaitForChild("UpperTorso").DashParticle
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {script.Parent.Parent}
Params.FilterType = Enum.RaycastFilterType.Blacklist
newHitbox.RaycastParams = Params
local Canrun = true
function Dash (Input)
if Input.UserInputType == Enum.UserInputType.Keyboard and Canrun == true then
if Input.KeyCode == Enum.KeyCode.LeftShift and Humanoid.MoveDirection.Magnitude > 0 and Humanoid:GetState() ~= Enum.HumanoidStateType.Freefall then
Canrun = false
DashParticle.Enabled = true
Humanoid.JumpPower = 0
script:SetAttribute("Dashing",true)
local v = Instance.new("BodyPosition")
v.MaxForce = Vector3.new(99999,0,0)
v.P = 30000
v.D = 2000
v.Position = (Character.Head.CFrame*Vector3.new(0,0,-130))
v.Parent = Character.Head
wait(0.001)
v:Destroy()
wait(0.5)
DashParticle.Enabled = false
Canrun = true
script:SetAttribute("Dashing",false)
Humanoid.JumpPower = 70
elseif Input.KeyCode == Enum.KeyCode.LeftShift and Humanoid.MoveDirection.Magnitude > 0 and Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
Canrun = false
DashParticle.Enabled = true
script:SetAttribute("Dashing",true)
newHitbox:HitStart()
local v = Instance.new("BodyPosition")
v.MaxForce = Vector3.new(70000,0,0)
v.P = 30000
v.D = 2000
v.Position = (Character.Head.CFrame*Vector3.new(0,0,-130))
v.Parent = Character.Head
newHitbox.OnHit:Connect(function(hit, humanoid)
local Bv = Instance.new("BodyPosition")
Bv.MaxForce = Vector3.new(90000,90000,90000)
Bv.P = 30000
Bv.D = 2000
Bv.Position = hit.Parent.Head.CFrame.LookVector * -100
Bv.Parent = hit.Parent.Head
print(hit)
humanoid:TakeDamage(5)
end)
wait(0.001)
v:Destroy()
wait(0.5)
DashParticle.Enabled = false
Canrun = true
script:SetAttribute("Dashing",false)
newHitbox:HitStop()
end
end
end
function KeyPressEnded (Input)
end
UIS.InputBegan:Connect(Dash)
UIS.InputEnded:Connect(KeyPressEnded)
the section that suppose to push the enemies:
newHitbox.OnHit:Connect(function(hit, humanoid)
local Bv = Instance.new("BodyPosition")
Bv.MaxForce = Vector3.new(90000,90000,90000)
Bv.P = 30000
Bv.D = 2000
Bv.Position = hit.Parent.Head.CFrame.LookVector * -100
Bv.Parent = hit.Parent.Head
print(hit)
humanoid:TakeDamage(5)
end)