My player won’t reset when on a team which makes them sort of invincible to losing, meaning health bar shows 0 but the don’t die.I would like to know some reasons why this could happen to atleast know where to try off
Any help would be helpful
Idk what the error could be but that’s what I would do:
1.First Check the Output
2.Maby a Studio Bug you could just delete the Team and recreate it.
3.You can try to deactivate all scripts in your game.
4.If the Problem is still there you can Report it under the category Bug Report in DEV forum.
Hope that helps
How are you getting to 0 health? Make sure you’re not accidentally just doing stuff on the client side.
By resetting
This problem seems to be quite ambiguous bcause there are lots of possibilities ![]()
This error most likely happen inside a LocalScript, so can you give us some code snippets that you believe could be the main problem?
Could it be a problem with the code in your game?
i have a ragdoll module
local RagdollModule = {}
-- Original configuration by CompletedLoop
local attachmentCFrames = {
["Neck"] = {CFrame.new(0, 1, 0, 0, -1, 0, 1, 0, -0, 0, 0, 1), CFrame.new(0, -0.5, 0, 0, -1, 0, 1, 0, -0, 0, 0, 1)},
["Left Shoulder"] = {CFrame.new(-1.3, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1), CFrame.new(0.2, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1)},
["Right Shoulder"] = {CFrame.new(1.3, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), CFrame.new(-0.2, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)},
["Left Hip"] = {CFrame.new(-0.5, -1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1), CFrame.new(0, 1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1)},
["Right Hip"] = {CFrame.new(0.5, -1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1), CFrame.new(0, 1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1)},
}
-- Names of instances created by the ragdoll system, used for cleanup.
local ragdollInstanceNames = {
["RagdollAttachment"] = true,
["RagdollConstraint"] = true,
["ColliderPart"] = true,
}
-- ========================================
-- RAGDOLL STATE MANAGER
-- ========================================
local RagdollStates = {}
local MaxUnragdollWaitTime = 5
local function GetRagdollState(character)
local key = tostring(character)
if not RagdollStates[key] then
RagdollStates[key] = {
isRagdolled = false,
currentThread = nil,
isDead = false,
failsafeThread = nil,
}
end
return RagdollStates[key]
end
function RagdollModule.CleanupRagdollState(character)
local key = tostring(character)
if RagdollStates[key] then
if RagdollStates[key].currentThread then
task.cancel(RagdollStates[key].currentThread)
end
if RagdollStates[key].failsafeThread then
task.cancel(RagdollStates[key].failsafeThread)
end
RagdollStates[key] = nil
end
end
-- ========================================
-- FAILSAFE SYSTEM
-- ========================================
local function StartFailsafeTimer(character: Model)
local state = GetRagdollState(character)
-- Cancel existing failsafe if any
if state.failsafeThread then
task.cancel(state.failsafeThread)
state.failsafeThread = nil
end
state.failsafeThread = task.delay(6.5, function()
local humanoid = character:FindFirstChild("Humanoid")
if not character.Parent then
state.failsafeThread = nil
return
end
if not humanoid or humanoid.Health <= 0 then
state.failsafeThread = nil
return
end
if state.isRagdolled then
RagdollModule.Fire(character, false)
state.isRagdolled = false
end
state.failsafeThread = nil
end)
end
local function CancelFailsafeTimer(character: Model)
local state = GetRagdollState(character)
if state.failsafeThread then
task.cancel(state.failsafeThread)
state.failsafeThread = nil
end
end
--================---- Private Functions ----================--
-- Allows for proper limb collisions
local function createColliderPart(part: BasePart)
if not part or part:FindFirstChild("ColliderPart") then return end
local rp = Instance.new("Part")
rp.Name = "ColliderPart"
rp.Size = part.Size / 1.7
rp.Massless = true
rp.CFrame = part.CFrame
rp.Transparency = 1
rp.CanCollide = true
rp.Anchored = false
rp.CollisionGroup = "plrs"
local wc = Instance.new("WeldConstraint")
wc.Part0 = rp
wc.Part1 = part
wc.Parent = rp
rp.Parent = part
end
-- Converts Motor6D's into BallSocketConstraints to enable ragdoll physics
local function replaceJoints(character: Model)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
humanoid.AutoRotate = false
for _, motor: Motor6D in ipairs(character:GetDescendants()) do
if motor:IsA("Motor6D") and attachmentCFrames[motor.Name] then
motor.Enabled = false
local a0 = Instance.new("Attachment", motor.Part0)
a0.Name = "RagdollAttachment"
a0.CFrame = attachmentCFrames[motor.Name][1]
local a1 = Instance.new("Attachment", motor.Part1)
a1.Name = "RagdollAttachment"
a1.CFrame = attachmentCFrames[motor.Name][2]
createColliderPart(motor.Part1)
local b = Instance.new("BallSocketConstraint", motor.Parent)
b.Name = "RagdollConstraint"
b.Attachment0 = a0
b.Attachment1 = a1
b.Radius = 0.15
b.LimitsEnabled = true
b.TwistLimitsEnabled = false
b.MaxFrictionTorque = 0
b.Restitution = 0
b.UpperAngle = 90
b.TwistLowerAngle = -45
b.TwistUpperAngle = 45
if motor.Name == "Neck" then
b.TwistLimitsEnabled = true
b.UpperAngle = 45
b.TwistLowerAngle = -70
b.TwistUpperAngle = 70
end
end
end
humanoid.AutoRotate = false
end
-- Destroys all ragdoll instances and re-enables the Motor6D's
local function resetJoints(character: Model)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health < 1 then
return
end
for _, instance in ipairs(character:GetDescendants()) do
if ragdollInstanceNames[instance.Name] then
instance:Destroy()
end
if instance:IsA("Motor6D") then
instance.Enabled = true
end
end
humanoid.AutoRotate = true
end
-- Sets up the character for ragdolling once.
function RagdollModule.setupCharacter(character: Model)
if character:GetAttribute("RagdollReady") then return end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
-- Necessary for Ragdolling to function properly
humanoid.RequiresNeck = false
humanoid.BreakJointsOnDeath = false
if not character:FindFirstChild("IsRagdoll") then
local RagdollValue = Instance.new("BoolValue")
RagdollValue.Name = "IsRagdoll"
RagdollValue.Parent = character
end
character:SetAttribute("RagdollReady", true)
local torso = character:FindFirstChild("Torso")
character:FindFirstChild("IsRagdoll").Changed:Connect(function(isRagdolling)
pcall(function()
torso:SetNetworkOwner(game.Players:GetPlayerFromCharacter(character))
end)
if not isRagdolling then
for _, part in ipairs(character:GetDescendants()) do
if part:IsA("BasePart") then
part.CollisionGroup = "plrs"
end
end
resetJoints(character)
CancelFailsafeTimer(character)
else
for _, part in ipairs(character:GetDescendants()) do
if part:IsA("BasePart") then
part.CollisionGroup = "Default"
end
end
replaceJoints(character)
StartFailsafeTimer(character)
end
end)
end
--================---- Public Functions ----=================--
---Toggles the ragdoll state for a given character.
---@param character Model The character model to ragdoll.
---@param isRagdolling boolean True to enable ragdoll, false to disable.
function RagdollModule.Fire(character: Model, isRagdolling: boolean)
if not character or not character:IsA("Model") then
return
end
local isRagdollValue = character:FindFirstChild("IsRagdoll")
if not isRagdollValue then
return
end
isRagdollValue.Value = isRagdolling
end
---Sets ragdoll state with optional automatic unragdoll after duration
---@param character Model The character model to ragdoll
---@param enabled boolean True to enable ragdoll, false to disable
---@param duration number Optional duration in seconds before automatic unragdoll
function RagdollModule.SetRagdoll(character: Model, enabled: boolean, duration: number?)
local state = GetRagdollState(character)
local humanoid = character:FindFirstChild("Humanoid")
local hrp = character:FindFirstChild("HumanoidRootPart")
if not humanoid or not hrp then
return
end
-- Cancel any existing unragdoll thread
if state.currentThread then
task.cancel(state.currentThread)
state.currentThread = nil
end
-- If character is dead, keep ragdolled
if state.isDead then
if not state.isRagdolled then
RagdollModule.Fire(character, true)
state.isRagdolled = true
end
return
end
if enabled then
-- Enable ragdoll
if not state.isRagdolled then
RagdollModule.Fire(character, true)
state.isRagdolled = true
character.HumanoidRootPart:ApplyAngularImpulse(Vector3.one * math.random(-15, 15) * 100)
end
-- Schedule unragdoll if duration is provided
if duration then
state.currentThread = task.delay(math.min(duration, MaxUnragdollWaitTime), function()
if not character.Parent or not humanoid or humanoid.Health <= 0 then
state.currentThread = nil
return
end
local startTime = os.clock()
local maxWaitTime = math.max(0, MaxUnragdollWaitTime - duration)
-- Wait for character to settle
while os.clock() - startTime < maxWaitTime do
if not character.Parent or not humanoid or humanoid.Health <= 0 then
state.currentThread = nil
return
end
if hrp.AssemblyLinearVelocity.Magnitude < 7 then
break
end
task.wait(0.1)
end
if character.Parent and humanoid and humanoid.Health > 0 and state.isRagdolled then
RagdollModule.Fire(character, false)
state.isRagdolled = false
end
state.currentThread = nil
end)
end
else
-- Disable ragdoll immediately
if state.isRagdolled and humanoid.Health > 0 then
RagdollModule.Fire(character, false)
state.isRagdolled = false
end
end
end
---Marks character as dead in ragdoll state
---@param character Model The character model
function RagdollModule.MarkDead(character: Model)
local state = GetRagdollState(character)
state.isDead = true
end
return RagdollModule
comments arent by me
The module works as intended and has no problems whatsoever
Can you screenrecord what the problem looks like? Sorry but we really dont get you just by your explanation ![]()
Seems like a problem with the respawn time
Try searching any scripts that may interact with .RespawnTime because blox did register death, just not its respawn ![]()
I used ctrl shift F and looked like 8 times. It’s not respawn time. I guess another detail that could help is the fact that this only happens on one team. My blue team. Resetting there is the only place that causes issue.
I think I can easily fix this issue only if I can detect when a player tries to reset. How can I?
I notice the character doesn’t fall apart after dying, is this intended? I’m wondering if that’s part of the respawn bug or not. I saw there was a ragdoll script, but I’m not sure if that script makes the character rigid or not. ![]()
Does disabling the ragdoll script have any effect on whether the characters can respawn or not? If disabling the script fixes the issue, the issue is likely somewhere in the script.
One way to detect when the player reaches zero health is by connecting a function to the Died event. This is not exclusive to respawns (characters can be eliminated by opponents as well), but would likely fire when a character respawns.
Notably, according to the documentation, “If the Dead Enum.HumanoidStateType is disabled [the Died event] will not fire.” I don’t know if that ragdoll script disables this Enum state or not.
thanks this helped actually, although there was no script disabling the state type, with some print statements I found out my ragdoll died event was not firing for blue members for some odd reason.
local function SetupDeathRagdoll(character)
local humanoid = character:WaitForChild("Humanoid")
warn("Setting connection") -- prints for all
humanoid.Died:Connect(function()
RagdollModule.MarkDead(character)
RagdollModule.SetRagdoll(character, true, nil)
warn("death") -- only prints for red team
task.delay(3, function()
RagdollModule.CleanupRagdollState(character)
end)
end)
end
by the way blue team and red team are treated more or less the same. Except red team gets a local script activated to them. Both teams are only teleported and given different tools. Any idea how this issue occurs?
That’s a good observation! I think qushenya is right that the character is dying, but not respawning because according to this segment of code, the RagdollModule functions only fire after the character dies.
In Players, there is a boolean value called CharacterAutoLoads, which controls whether characters are automatically loaded in. Is CharacterAutoLoads enabled or disabled? If this value is disabled, code will need to use :LoadCharacter() in order to respawn a character.
If the previous solution doesn’t work, what is the LocalScript Red Team gets? Wondering if this LocalScript changes anything. or is in any way related to character respawning.
character autoload is enabled. And equipping tools after respawn time kill actually reset the player. its really weird.
I fixed the resetting issue be removing resetting. Genius Ik.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.