local hitbox = {}
local hitboxTransparency = 1
local hitboxLifeSpan = 0.2
local hitboxPrediction = 6
local hitboxOffset = 3
local ragdoll = require(game.ReplicatedStorage.Ragdoll)
local ragdollDuration = 2
local force = 200
function hitbox.AtkHitbox(player: Player, size: Vector3, damage: NumberValue, row: NumberValue)
local c = player.Character
local r = c:FindFirstChild("HumanoidRootPart")
local datatable = {}
if c then
local h = Instance.new("Part")
h.Parent = workspace
h.Position = r.Position + (r.CFrame.LookVector * hitboxOffset) + Vector3.new(r.Velocity.X, 0, r.Velocity.Z) / hitboxPrediction
h.Size = size
h.Transparency = hitboxTransparency
h.Anchored = true
h.CanCollide = false
h.Name = "AtkHitbox"
task.delay(hitboxLifeSpan, function()
h:Destroy()
end)
h.Touched:Connect(function(p)
if p.Parent and p.Parent:FindFirstChild("Humanoid") and p.Parent ~= c then
local hc = p.Parent
if not table.find(datatable, hc.Name) then
table.insert(datatable, hc.Name)
local th = hc:FindFirstChild("Humanoid")
if row ~= 4 then
th:TakeDamage(damage)
else
th:TakeDamage(damage * 2)
ragdoll.Start(hc)
local hrp = hc:FindFirstChild("HumanoidRootPart")
if hrp then
local forceDirection = (r.CFrame.LookVector + Vector3.new(0, 0.5, 0)) * force
hrp:ApplyImpulse(forceDirection * hrp.AssemblyMass)
end
delay(ragdollDuration, function()
ragdoll.Stop(hc)
end)
end
end
end
end)
end
end
return hitbox
In this particular function, i want to set the network ownership to the attacker (player) so the force applied to the hit player wont delay on players pov. How can i do that?