So i was tryna make a knockback system, everything seems to be correct, and there isn’t any error message, Yet it still doesn’t knock the player back
ServerScript
fistm2.OnServerEvent:Connect(function()
local chr = player.Character
chr:SetAttribute("IsAttacking", true)
local bloodvfx = rs:WaitForChild("BloodVfx")
local hrp = chr.PrimaryPart
local hitboxCFrame = chr.HumanoidRootPart.CFrame * CFrame.new(0,0,0)
local hitboxSize = Vector3.new(10,5,20)
local damage = 18
local hitbox = rs.Hitbox:Clone()
hitbox.Parent = workspace
hitbox.CFrame = hitboxCFrame
hitbox.Size = Vector3.new(hitboxSize, hitboxSize, hitboxSize)
local hitcontent = workspace:GetPartBoundsInBox(hitboxCFrame, hitboxSize)
local hitlist = {}
for _,v in pairs(hitcontent) do
if v.Parent:FindFirstChild("Humanoid") and v.Parent ~= chr and not table.find(hitlist, v.Parent) then
table.insert(hitlist, v.Parent)
KnockBackModule.start(v.Parent, (v.Parent:FindFirstChild("HumanoidRootPart").Position - chr.PrimaryPart).Unit * Vector3.new(60,0,60) + Vector3.new(0,40) )
v.Parent.Humanoid:TakeDamage(damage)
v.Parent:SetAttribute("Stunned", true)
end
end
task.wait(1)
chr:SetAttribute("IsAttacking", false)
end)
Module script
local kb = {}
kb.start = function(character, direction)
local hrp = character:FindFirstChild("HumanoidRootPart")
if hrp = nil then return end
local att == Instance.new("Attachment", hrp)
local lv = Instance.new("LinearVelocity", att)
lv.MaxForce = 9999999
lv.VectorVelocity = direction
lv.Attachment0 = att
print("this even work?")
game.Debris:AddItem(lv, 0.1)
end
return kb