Infinite yield possible when object is in the correct place

Im replicating this part from replicated storage that’s supposed to be parented and located inthe player’s right leg. It has “dmg points” attachments in the part so I can use RaycastHitboxV4. Problem is that the game wont detect the part itself :confused: and adding a timeout does nothing as you can see it will return nil when I print it on line 54.

-- Local Script under StarterCharacterScript --

local char = game.Players.LocalPlayer.Character
print(char)
		
local RightLeg = char:WaitForChild("Right Leg") 

local part = game:GetService("ReplicatedStorage").Assets.Weapons.RLeg:Clone()
part.Parent = RightLeg
part.CanCollide = false
part.Anchored = false

local weld = Instance.new("Motor6D", RightLeg)
weld.C0 = game:GetService("ReplicatedStorage").Assets.Weapons.Motor6D.C0
weld.C1 = game:GetService("ReplicatedStorage").Assets.Weapons.Motor6D.C1
weld.Part0 = RightLeg
weld.Part1 = part

Server script is really long so I will only add lines 51- 58 as its important

-- Server script--
playSwingAnimation:GetMarkerReachedSignal("hitstart"):Connect(function()
		if char:GetAttribute("Combo") == MaxCombo then
			print("this will print")
			print(char["Right Leg"]:WaitForChild("RLeg",0.01))
			RaycastHitbox.new(char["Right Leg"]:WaitForChild("RLeg"))
		end
		Hitbox:HitStart()
	end)

Try to task.wait(5) before calling :WaitForChild(). If it does work by waiting then slowly move the time down.
Also make sure that there is only one object called “Right Leg” under the model, if there are multiple it will not work.
I also suggest to WaitForChild for at least 0.5 seconds.

Thanks for your reply in the screenshot I attached if you like at the properties tab at the right tab you can see the hierarchy I took while in game. This part is supposed to be put into the player’s right leg. I added a task.wait before i define RLeg at the top and used it for RaycastHitbox.new but it still gives me the same warning, only longer now because of the wait

Alright let’s start debugging, for loop through the children of the Right Leg, before you WaitForChild.

for _, child in pairs(char["Right Leg"]:GetChildren()) do
   print(child.Name, child.Name == "RLeg")
end

it just prints out
RightFootAttachment false

Even though it clearly shows that its under Right leg in the explorer tab im not sure if it has to do with the part actually being a mesh part and not a part

you’re cloning the part on the client to the player and trying to find it on the server this does not work because of filtering enabled, you will have to clone it on the server and weld it to the right leg

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.