Hi, im trying to implement :WaitForChild for its primary purpose (probably dont need to explain). However, i have two dilemas. 1. When i call the following code, I get a "Character" == nil --> error " attempt to index field 'Character' (a nil value)"
game:GetService("Players").LocalPlayer.Character:WaitForChild("LeftLowerLeg")
--repeat wait() until game.Players.LocalPlayer.Character.LeftLowerLeg
local feet = game:GetService("Players").LocalPlayer.Character.LeftLowerLeg
print("destroy")
wait(1)
feet:Destroy()
I tried to get past this by adding more wait for childs but i then got an infinite yield warning/error on trying to find the localplayer.
game:GetService("Players"):WaitForChild("LocalPlayer")
game:GetService("Players").LocalPlayer:WaitForChild("Character")
game:GetService("Players").LocalPlayer.Character:WaitForChild("LeftLowerLeg")
--repeat wait() until game.Players.LocalPlayer.Character.LeftLowerLeg
local feet = game:GetService("Players").LocalPlayer.Character.LeftLowerLeg
print("destroy")
wait(1)
feet:Destroy()
How do i fix this? Thanks

8 comments
repeat wait() until player.Character Works. local character = player.Character or player.CharacterAdded:Wait() is even better
"If your game does not have FilteringEnabled" FE is forced on all games
It can be turned off though, right? So if he had turned it off...
kinda, you can untick the checkbox for filtering enabled but that won't do anything. it can't be turned off. also, you can delete parts inside your character locally and theyll also delete on the server. not sure if this was intended by roblox or not.
I tried the repeat until thing as well. It doesnt fix the problem. if you look in the code above, you can see it. I commented it out i was testing it earlier.
I also havent meddled with filtering enabled. I just checked it again and can confirm that FilteringEnabled = true.
wait what xD. I tried the repeat thing again and it worked. thanks royaltoe.
update: it worked one time. going to add more info now below.