Character.parent is always nil

I’ve been working on a combat system lately and I noticed that after you die none of the animations work because the script is infinite looping because the character’s parent is always set to nil and it never gets changed to workspace so the script never continues I searched around the forum and I didnt seem to find any solution to this problem:


local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local debounce = false

local EssentialModules = game.ReplicatedStorage.EssentialModules
local rayhitboxes = require(EssentialModules.RaycastHitboxV3)

local status_module = require(game.ReplicatedStorage:FindFirstChild("Status_Module"))
local statusClient =

local combat_module = require(game.ReplicatedStorage:FindFirstChild("Combat_Module"))
local combatClient =

print(character.Parent) -- Prints nil
warn("Player still is not loaded")

                             -- this passes             this doesnt pass                        this passes
repeat wait() until player:FindFirstChild("Loaded") and character.Parent ~= nil and character:FindFirstChild("Humanoid")

warn("Player finished loading") -- This doesnt print because character.Parent doesnt change from nil
print(character.Parent) -- Should print workspace but the code never continues

Any help is appreciated

1 Like

Ok so I just added a wait(2) before line 1 and that seemed to fix it ? this whole error is confusing

1 Like

What do you mean by “loading”, do you mean as in that everything within their avatar has loaded, including accessories and shirts/pants/t-shirts?

You can use Player | Documentation - Roblox Creator Hub

1 Like

By “Loading” I mean the player has all the necessary values inside of him so the combat system can work properly

1 Like

Then you should read my comment above, and use a repeat loop to wait for your custom values.

1 Like

My problem is that I couldnt play animations because the character’s parent was still set to nil and not workspace, to further understand what I mean

1 Like

Try using Player.CharacterAppearanceLoaded.

1 Like

I had this same issue just now. The solution was to just spam char = player.Character until char stopped having a nil parent. In code:

local player = game.Players.LocalPlayer

local char = player.Character or player.CharacterAdded:Wait()

while char.Parent == nil do

char = player.Character