Hello everyone!
I’ve been working on a combat system for my game, but I’ve noticed that while it works (almost) perfectly on dummies, it feels laggy or delayed when applied to real players. The combat system works so it first knockbacks, waits 0.1s and ragdolls the target. I tested some things and Knockback itself works smooth, ragdoll itself works smooth but knockback + ragdoll isn’t.
Video:
Knockback script:
for _, targetParts in pairs(hitCharacter:GetDescendants()) do
if targetParts:IsA("BasePart") and targetParts:CanSetNetworkOwnership() then
targetParts:SetNetworkOwner(nil)
print(targetParts)
end
end
task.wait()
local direction = (hitCharacter.HumanoidRootPart.Position - character.HumanoidRootPart.Position).Unit
local knockbackForce = direction * 65 + Vector3.new(0, 50, 0)
hitCharacter.HumanoidRootPart.AssemblyLinearVelocity = knockbackForce
task.spawn(function()
task.wait(.1)
RagdollTest.Start(hitCharacter, 2)
end)
Ragdoll script:
function Ragdoll.Start(Character : Model, Duration : number)
if Character == nil then
return
end
local Humanoid : Humanoid = Character:WaitForChild("Humanoid")
local RootPart = Humanoid.RootPart
if Character:GetAttribute("Ragdolled") then
return
end
local Impact : RBXScriptConnection
Sockets[Character] = {}
Colliders[Character] = {}
Attachments[Character] = {}
Character:SetAttribute("Ragdolled", true)
local iframe = Instance.new("BoolValue", Character)
iframe.Name = "Iframe"
local stun = Instance.new("BoolValue", Character)
stun.Name = "Stun"
Humanoid.RequiresNeck = false
Humanoid.PlatformStand = true
Humanoid.AutoRotate = false
for _, Item in ipairs(Character:GetDescendants()) do
if Item:IsDescendantOf(RootPart) then
continue
end
if Item:FindFirstAncestorWhichIsA("Model") ~= Character then
continue
end
if Item:IsA("Motor6D") then
CreateCollider(Item.Part1, Character)
Item.Enabled = false
local Attachment0 = Instance.new("Attachment")
Attachment0.CFrame = Item.C0
Attachment0.Parent = Item.Part0
local Attachment1 = Instance.new("Attachment")
Attachment1.CFrame = Item.C1
Attachment1.Parent = Item.Part1
local Socket = Instance.new("BallSocketConstraint")
Socket.Attachment0 = Attachment0
Socket.Attachment1 = Attachment1
Socket.LimitsEnabled = true
Socket.UpperAngle = 30
Socket.TwistLimitsEnabled = true
Socket.Restitution = 0.1
Socket.Parent = Item.Parent
Sockets[Character][Item] = Socket
table.insert(Attachments[Character], Attachment0)
table.insert(Attachments[Character], Attachment1)
end
end
if Duration ~= nil then
task.delay(Duration, function()
Ragdoll.Stop(Character)
end)
end
end
If there’s anything you could think of, I will be grateful for any help.