Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Player died script refusing to work?

Asked by 6 years ago

I was scripting this tool in which when the player dies, it clones the player and leaves it on the floor as if it was a dead body. But so far, it only gets past the cloning stage. I get multiple errors like " 'player' is not a valid member of workspace' and 'Humanoid is not a valid member of model.'

PlayerList = {}

game.Players.PlayerAdded:connect(function(player)
    table.insert(PlayerList, player.Name)
    player.Archivable = true
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            print(player.character.Name)
            print(player.Name)
            local toolclones = game.Workspace[player.Name]
            toolclones.Archivable = true
            toolclones:Clone().Parent = game.Workspace
            if toolclones == nil then
                toolclones.Name = player.Name.."-Dead"
            end
                        toolclones:WaitForChild("Humanoid")
            toolclones.Archivable = true
            toolclones.Humanoid = Enum.HumanoidDisplayDistanceType.None
            toolclones.Humanoid = Enum.HumanoidStateType.Seated
            toolclones.Humanoid.AutoJumpEnabled = false
        end)
    end)
end)

1) Is it possible to rename a humanoid that is cloned? 2) Why is the humanoid and the model refusing to pick up at times?

Thanks.

1 answer

Log in to vote
0
Answered by 6 years ago

Lines 18 and 19

--You forgot ".DisplayDistanceType"
toolclones.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
--Then you change the state with ChangeState() function
toolclones.Humanoid:ChangeState(Enum.HumanoidStateType.Seated) 

1) Yes it is possible to rename a Humanoid that is cloned

2) Why are your Humanoid and Model nil? Because your character just died and the parts are removed. You never set toolclones to an actual Clone it's still game.Workspace[player.Name]

Ad

Answer this question