Value Waiting For Child Not Working

I am making a system and I have this point where it gets a value and uses it but when I wait for child sometimes this errors appears, anyone know why?
image

This is the line of code:
local combatengage = plr.Character:WaitForChild("combatLockClient").combatEngage

Your gonna need to show more of the code.

Maybe at times, the Character of the player is not loaded yet.
Try changing to:

local char = plr.Character or plr.CharacterAdded:Wait()
local combatengage = char:WaitForChild("combatLockClient").combatEngage
1 Like

Most likely, your line of code is attempting to run before the Character has spawned. So you need to wait for the character first.

Since it’s in a Backpack which refreshes on each spawn, it could look something like this:

local character = plr.Character or plr.CharacterAdded:Wait()
local combatengage = character:WaitForChild("combatLockClient").combatEngage

Edit: Absolutely ninja’d by @Daronion lol

1 Like