I'm currently making a ragdoll death system in my horror game. When the player dies to the monster, it ragdolls. The monster anchors the player and jumpscares the player. The death has a two-second delay. It works fine, but when I use the ragdoll death script, the jumpscare won't let the player respawn, and the monster keeps damaging the player for multiple times. I also noticed that when I anchor the player and set the health to 0, it doesn't respawn and quickly regenerates health, and I had to set the health to 0 to actually make the player respawn. Is it because "BreakJointsOnDeath" is set to false? Please tell me solutions because I can't figure out a way to fix it. Thanks!
Ragdoll Script (where the main problem is):
local Players = game:GetService("Players") local character= script.Parent local player= Players:GetPlayerFromCharacter(character) if character and player then local humanoid = character:FindFirstChildOfClass("Humanoid") local rootPart = character:FindFirstChild("HumanoidRootPart") if humanoid and rootPart then humanoid.BreakJointsOnDeath = false humanoid.Died:Connect(function() for _, descendant in pairs(character:GetDescendants()) do if (descendant:IsA("Motor6D") or descendant:IsA("Motor")) and (descendant.Name ~= "Neck") then local mahballzSocket = Instance.new("BallSocketConstraint") local attachment0 = Instance.new("Attachment") local attachment1 = Instance.new("Attachment") attachment0.CFrame = descendant.C0 attachment1.CFrame = descendant.C1 attachment0.Parent = descendant.Part0 attachment1.Parent = descendant.Part1 mahballzSocket.LimitsEnabled = true mahballzSocket.TwistLimitsEnabled = true mahballzSocket.Attachment0 = attachment0 mahballzSocket.Attachment1 = attachment1 mahballzSocket.Parent = descendant.Parent descendant:Destroy() end end rootPart.CanCollide = false end) end end
Monster AI (in case you want to see it):
-- part of the ai script that jumpscares the player function Attack(target) local distance = (monsterRoot.Position - target:WaitForChild("HumanoidRootPart").Position).Magnitude if distance > (HitboxLength) then --local monsterToTargetPath = GetPath(target:WaitForChild("HumanoidRootPart")) chasing.Value = true monsterHumanoid.WalkSpeed = chaseSpeed monsterHumanoid:MoveTo(target:WaitForChild("HumanoidRootPart").Position, target:WaitForChild("HumanoidRootPart")) --[[ for _, waypoint in pairs(monsterToTargetPath:GetWaypoints()) do monsterHumanoid:MoveTo(waypoint.Position) end]] else monsterHumanoid.WalkSpeed = normalSpeed chasing.Value = false repeat task.wait() until jumpscareAnim.Length > 0 jumpscareAnim:Play() --target:FindFirstChildOfClass("Humanoid"):TakeDamage(target:FindFirstChildOfClass("Humanoid").MaxHealth) local JumpscareFinished = ReplicatedStorage:WaitForChild("Jumpscare"):InvokeClient(Players:GetPlayerFromCharacter(target), monster, jumpscareAnim.Length) repeat task.wait() until ((JumpscareFinished ~= nil) and (JumpscareFinished == true)) jumpscareAnim:Stop() print("Finished!") end end
Jumpscare Script:
local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local TweenService = game:GetService("TweenService") local player = Players.LocalPlayer or Players:GetPlayerFromCharacter(script.Parent) local character = ((player.Character or player.CharacterAdded:Wait()) or script.Parent) local camera = workspace.CurrentCamera ReplicatedStorage:WaitForChild("Jumpscare").OnClientInvoke = function(monster, animLength) if (monster ~= nil) and (monster:FindFirstChildOfClass("Humanoid")) and (monster:FindFirstChild("Head")) and (monster:FindFirstChild("HumanoidRootPart")) then local monsterHumanoid = monster:FindFirstChildOfClass("Humanoid") local monsterHead = monster:FindFirstChild("Head") local monsterRoot = monster:FindFirstChild("HumanoidRootPart") local JumpscareBox = monsterHead:FindFirstChild("JumpscareBox") if (JumpscareBox ~= nil) then camera.CameraType = Enum.CameraType.Scriptable camera.CFrame = JumpscareBox.CFrame monsterRoot.Anchored = true character:WaitForChild("HumanoidRootPart").Anchored = true for i, v in pairs(character:GetDescendants()) do if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("UnionOperation") or v:IsA("Decal") then v.Transparency = 1 end end task.delay(2, function() ReplicatedStorage:WaitForChild("Death"):Fire(character) end) task.wait(animLength) for i, v in pairs(character:GetDescendants()) do if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("UnionOperation") or v:IsA("Decal") then v.Transparency = 0 end end camera.CameraType = Enum.CameraType.Custom monsterRoot.Anchored = false character:WaitForChild("HumanoidRootPart").Anchored = false return true end end end
Death Screen Script:
game.ReplicatedStorage.Death.Event:Connect(function(character) script.Parent.Visible = true character:WaitForChild("Humanoid"):TakeDamage(character:WaitForChild("Humanoid").MaxHealth) end)