#The Humanoid with 0 hp doesn't respawn
1 messages · Page 1 of 1 (latest)
** You are now Level 2! **
wait
The humanoid isn't respawning if it's interacted with a mop: hitted or got hit
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debris = game:GetService("Debris")
local Modules = ReplicatedStorage:WaitForChild("Modules")
local Ragdoll = require(Modules:WaitForChild("RagdollModule"))
local WeaponStats = require(Modules:WaitForChild("MopsData"))
local cooldowns = {}
local function getTargets(hitbox, attackerChar)
local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Blacklist
params.FilterDescendantsInstances = { attackerChar }
local parts = workspace:GetPartBoundsInBox(hitbox.CFrame, hitbox.Size, params)
local targets = {}
for _, part in ipairs(parts) do
local char = part:FindFirstAncestorOfClass("Model")
local hum = char and char:FindFirstChildOfClass("Humanoid")
if hum and hum.Health > 0 then
targets[char] = hum
end
end
return targets
end
local function applyKnockback(character, direction, force)
local hrp = character:FindFirstChild("HumanoidRootPart")
if not hrp then return end
local bv = Instance.new("BodyVelocity")
bv.Name = "Knockback"
bv.MaxForce = Vector3.new(1e5, 1e5, 1e5)
bv.P = 1e4
bv.Velocity = direction * force + Vector3.new(0, force * 0.35, 0)
bv.Parent = hrp
Debris:AddItem(bv, 0.25)
end```
if cooldowns[player] then return end
cooldowns[player] = true
local character = player.Character
if not character then return end
local hrp = character:FindFirstChild("HumanoidRootPart")
if not hrp then return end
local hitbox = tool:FindFirstChild("Hitbox")
if not hitbox then return end
local stats = WeaponStats[tool.Name] or WeaponStats.Basic
local targets = getTargets(hitbox, character)
for targetChar, humanoid in pairs(targets) do
local healthBefore = humanoid.Health
humanoid:TakeDamage(stats.Damage)
if humanoid.Health <= 0 then
continue
end
if humanoid.Health > 0 then
local lookDir = hrp.CFrame.LookVector
local flatDir = Vector3.new(lookDir.X, 0, lookDir.Z).Unit
applyKnockback(targetChar, flatDir, stats.Knockback)
Ragdoll.Ragdoll(targetChar)
task.delay(stats.RagdollTime, function()
if humanoid and humanoid.Health > 0 then
Ragdoll.UnRagdoll(targetChar)
end
end)
end
end
task.delay(stats.Cooldown or 0.5, function()
cooldowns[player] = nil
end)
end
local function setupTool(tool, player)
if tool:GetAttribute("Connected") then return end
tool:SetAttribute("Connected", true)
tool.Activated:Connect(function()
hit(player, tool)
end)
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char.ChildAdded:Connect(function(child)
if child:IsA("Tool") and child:FindFirstChild("Hitbox") then
setupTool(child, player)
end
end)
end)
end)```
this isnt very clear
do you mean your npcs wont respawn or the player?
players aren't respawning
can you send me a screenshot of game.Players properties
Wait
I mean, earlier i've set a custom Avatar setting
s
And I think it might be cuz of it
interesting
its definitely a problem with your ragdoll module
im too tired rn and i gtg so ill help later
Alright