Im making a Knockback tool for my game but it push/knockback where the enemy is looking.
I want it so it knockback the enemy where the player that has the tool is looking.
The script I can runs fine.
local debounce = false
local hotdog = false
local player = script.Parent.Parent.Parent
local t = script.Parent
local Anim = t.Animation
script.Parent.Activated:Connect(function(P)
if debounce then return end
debounce = true
local char = t.Parent
local humanoid = char:WaitForChild("Humanoid")
local plays = humanoid:LoadAnimation(Anim)
plays:play()
print('ez')
script.Parent.Part.Touched:Connect(function(hit)
if hit and hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("HumanoidRootPart") then
if hotdog then return end
hotdog = true
local KnockBack = Instance.new("BodyVelocity")
KnockBack.Name = "Knockback"
KnockBack.MaxForce = Vector3.new(10000,10000,10000)
KnockBack.Velocity = (hit.Parent.HumanoidRootPart.CFrame.LookVector* -40 + Vector3.new(0,10,0))
KnockBack.Parent = hit.Parent.HumanoidRootPart
wait(0.25)
KnockBack.Velocity = Vector3.new(0,0,0)
KnockBack:Destroy()
player.leaderstats.Wacks.Value = player.leaderstats.Wacks.Value + 1
print("W")
else
return
end
end)
wait(0.5)
debounce = false
hotdog = false
end)
I assume you are talking about the rotation of the enemy’s HumanoidRootPart. In that case, you want to set the rotation of the enemy’s rootpart equal to the character’s, but plus 180 degrees on the y axis.
local debounce = false
local hotdog = false
local player = script.Parent.Parent.Parent
local t = script.Parent
local Anim = t.Animation
script.Parent.Activated:Connect(function(P)
if debounce then return end
debounce = true
local char = t.Parent
local humanoid = char:WaitForChild("Humanoid")
local plays = humanoid:LoadAnimation(Anim)
plays:play()
print('ez')
script.Parent.Part.Touched:Connect(function(hit)
if hit and hit.Parent:IsA("Model") and hit.Parent:FindFirstChild("HumanoidRootPart") then
if hotdog then return end
hotdog = true
local KnockBack = Instance.new("BodyVelocity")
KnockBack.Name = "Knockback"
KnockBack.MaxForce = Vector3.new(10000,10000,10000)
KnockBack.Velocity = (hit.Parent.HumanoidRootPart.CFrame.LookVector* -40 + Vector3.new(0,10,0))
hit.Parent.HumanoidRootPart.Rotation = player.Character.HumanoidRootPart.Rotation + Vector3.new(0,-180,0)
KnockBack.Parent = hit.Parent.HumanoidRootPart
wait(0.25)
KnockBack.Velocity = Vector3.new(0,0,0)
KnockBack:Destroy()
player.leaderstats.Wacks.Value = player.leaderstats.Wacks.Value + 1
print("W")
else
return
end
end)
wait(0.5)
debounce = false
hotdog = false
end)