I’m trying to make a combat system, and I’m currently working with ragdoll. The problem is that it is on the players after the end of the ragdoll that the player does not get up as usual, but gets stuck in the ground for one second, and then returns to a static position. I do not know how to fix it.
Server script:
local remote = game:GetService("ReplicatedStorage").Events.M1Event
local MaxCombo = 4
local hitboxsys = require(game.ServerStorage.Module.MuchachoHitbox)
local HitService = require(game.ServerStorage.Module.Hit)
local ragdollmodule = require(game.ServerStorage.Module.RagdollHandler)
local ragevent = game:GetService("ReplicatedStorage").Events.Ragdoll
local players = game:GetService("Players")
local function SetCombo(char)
local combo = char:GetAttribute("Combo")
if combo < MaxCombo then
char:SetAttribute("Combo", combo+1)
else
char:SetAttribute("Combo", 1)
end
end
local function ResetCombo(char, oldcombo)
task.delay(1, function()
local currentcombo = char:GetAttribute("Combo")
if oldcombo == 4 then return end
if currentcombo-1 == oldcombo and not char:GetAttribute("Attacking") then
char:SetAttribute("Combo", 1)
end
end)
end
remote.OnServerEvent:Connect(function(player)
local cantpunch = false
local char = player.Character
local humanoid = char:WaitForChild("Humanoid")
local rootpart = humanoid.RootPart
local animator = humanoid.Animator
local combo = char:GetAttribute("Combo")
local attacking = char:GetAttribute("Attacking")
local stunned = char:GetAttribute("Stunned")
if attacking or stunned or cantpunch then return end
char:SetAttribute("Attacking", true)
local animations = game.ReplicatedStorage["Combat anims"]:GetChildren()
local animation = animator:LoadAnimation(animations[combo])
local hitbox = hitboxsys.CreateHitbox()
if combo == MaxCombo then
hitbox.Size = Vector3.new(3.5,5,3.5)
else
hitbox.Size = Vector3.new(3,2.3,3.5)
end
hitbox.Offset = CFrame.new(0,0,-2.5)
hitbox.CFrame = rootpart
hitbox.Visualizer = false
local lasthitted = false
animation.Stopped:Connect(function()
ResetCombo(char, combo)
if combo == MaxCombo then
if lasthitted == false then
humanoid.WalkSpeed = 0.01
task.wait(0.7)
else
wait(0.1)
cantpunch = nil
lasthitted = false
humanoid.WalkSpeed = 21
task.wait(0.9)
cantpunch = false
end
end
humanoid.WalkSpeed = 21
char:SetAttribute("Attacking", nil)
hitbox:Stop()
end)
hitbox.Touched:Connect(function(hit, hum)
if hum == humanoid then return end
if combo < MaxCombo then
HitService.Hit(hum, 3, .3, nil)
else
local enemychar = hum.Parent
local state = "ragdolled"
lasthitted = true
local enemyname = hum.Parent.Name
local plr = game.Players:GetPlayerFromCharacter(enemychar)
if plr ~= nil then
local player = players[enemyname]
HitService.Hit(hum, 4, 2, rootpart.CFrame.LookVector*48)
ragdollmodule:Ragdoll(enemychar)
ragevent:FireClient(player, hum, state)
enemychar.HumanoidRootPart.CFrame = enemychar.HumanoidRootPart.CFrame * CFrame.Angles(math.pi*.27,0,0)
task.wait(2)
state = "noragdolled"
ragdollmodule:Recover(enemychar)
ragevent:FireClient(player, hum, state)
else
HitService.Hit(hum, 4, 2, rootpart.CFrame.LookVector*48)
ragdollmodule:Ragdoll(enemychar)
hum:ChangeState(Enum.HumanoidStateType.Physics)
enemychar.HumanoidRootPart.CFrame = enemychar.HumanoidRootPart.CFrame * CFrame.Angles(math.pi*.27,0,0)
task.wait(2)
ragdollmodule:Recover(enemychar)
hum:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end
end)
humanoid.WalkSpeed = 8
animation:Play()
task.wait()
hitbox:Start()
SetCombo(char)
end)
Module: Ragdoll module for all character - Resources / Community Resources - Developer Forum | Roblox
Also have a local:
local ragevent = game:GetService("ReplicatedStorage").Events.Ragdoll
Character = script.Parent.Parent --Target Character
local antirepeat = false
local ragdollmod = require(game.ServerStorage.Module.RagdollHandler)
if antirepeat == false then
ragdollmod:RigPlayer(Character)
end
Humanoid = Character:FindFirstChild("Humanoid")
--Double Check
if Humanoid == nil then
Humanoid = Character:WaitForChild("Humanoid") --Waits for object or the script fails.
end
Humanoid.BreakJointsOnDeath = false --Resures that the script is able to copy the old joints to create the ragdoll or else it will not work as it would destroy the Motor6D joints on death.
AlwaysFall = true --Always rotate the character backwards by a small amount so it can never be able to stand by itself and will always fall.
DestroyOldWelds = true --Destroy old welds or disable them.
repeat
wait(0.001)
if Humanoid.Health <= 0 then
if AlwaysFall == true then
Root = Character:FindFirstChild("HumanoidRootPart")
if Root then
Root.CFrame = Root.CFrame * CFrame.Angles(math.pi*.15,0,0) --Rotates the Root backward to always fall backwards of where the character is facing.
end
end
for i,Thing in ipairs(Character:GetDescendants()) do
if Thing:isA("Motor6D") then --Checks if its a Motor6D joint.
if Thing.Enabled == true then
Socket = Instance.new("BallSocketConstraint", Thing.Parent) --Creates replacement
Attachment0 = Instance.new("Attachment")
Attachment1 = Instance.new("Attachment")
Socket.Attachment0 = Attachment0
Socket.Attachment1 = Attachment1
Socket.Name = Thing.Name
Attachment0.Name = "Attachment0_"..Thing.Name
Attachment1.Name = "Attachment1_"..Thing.Name
--Sets parents
Attachment0.Parent = Thing.Part0
Attachment1.Parent = Thing.Part1
--Sets CFrames
Attachment0.CFrame = Thing.C0
Attachment1.CFrame = Thing.C1
--Etc
Socket.LimitsEnabled = true
Socket.TwistLimitsEnabled = true
Thing.Enabled = false
if DestroyOldWelds == true then
Thing:Destroy()
end
end
end
end
break --Stops loop.
end
until script.Disabled == true
ragevent.OnClientEvent:Connect(function(hum, state)
if hum.Health > 0 then
if state == "ragdolled" then
hum:ChangeState(Enum.HumanoidStateType.Physics)
elseif state == "noragdolled" then
hum:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end
end)