#Simple script is not working.

1 messages · Page 1 of 1 (latest)

vivid wyvern
#
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ragdollMod = require(ReplicatedStorage.Modules.RagdollModule)

local playerConnections = {}

local function characterInit(plr, char)
    local hum = char:WaitForChild("Humanoid", 10)
    if not hum then return end

    hum.BreakJointsOnDeath = false

    if playerConnections[plr.UserId] then
        playerConnections[plr.UserId]:Disconnect()
    end

    playerConnections[plr.UserId] = hum.Died:Connect(function()
        print(plr.Name .. " died.")
        ragdollMod.ToggleRagdoll(char, true)
    
        task.wait(3)
        if plr and plr.Parent then
            plr:LoadCharacter()
        end
    end)
end

Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        characterInit(plr, char)
    end)

    if plr.Character then
        characterInit(plr, plr.Character)
    end
end)

Players.PlayerRemoving:Connect(function(plr)
    if playerConnections[plr.UserId] then
        playerConnections[plr.UserId]:Disconnect()
        playerConnections[plr.UserId] = nil
    end
end) ```
#

No matter what I do it never fires the death connection and character added