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?
This is the line of code:
local combatengage = plr.Character:WaitForChild("combatLockClient").combatEngage
Your gonna need to show more of the code.
Daronion
(Daronion)
#3
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
sleitnick
(sleitnick)
#4
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