Script breaks when someone wears custom bodyparts

Hello!
This is my script:

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		local clone = game.ServerStorage.PlayerInfoPart:Clone()
		clone.Parent = char:WaitForChild("UpperTorso")
		clone.WeldConstraint.Part1 = char:WaitForChild("HumanoidRootPart")
		clone.Position = char:WaitForChild("HumanoidRootPart").Position
	end)
end)

It’s supposed to clone a hitbox (playerinfopart) into the players’ character. This does only work when you have a blocky avatar. I tried this with a baconhair default avatar (man arms/legs/torso/head) and the hitbox wasn’t in my character. The game is R15 only and the baconhair also has a UpperTorso. It doesn’t give me any errors. The hitbox just won’t get cloned.

Maybe try this?

game.Players.PlayerAdded:Connect(function(plr)
    print("Player added")
	plr.CharacterAdded:Connect(function(char)
        print("Test")
		local clone = game.ServerStorage.PlayerInfoPart:Clone()
		clone.Parent = char:WaitForChild("UpperTorso") 
		clone.WeldConstraint.Part1 = char:WaitForChild("HumanoidRootPart")
		clone.Position = char:WaitForChild("HumanoidRootPart").Position
        print("Test 2")
	end)
end)
1 Like

Thanks, it prints all of this. Still no error message etc. :c

Could it be possible that the Part keeps falling? Or the weld isn’t being assigned right? Not sure why it’s happening, you could try checking the Explorer & see where the Part goes after you respawn once

1 Like

I checked my character in the explorer when I had the man body parts. The hitbox wasn’t there. Also the welding worked when I had a blocky avatar.

Only thing I can think of printing out the clone’s Parent, it could be disappearing way too fast?

1 Like

It says it’s nil (reply must be longer)

Did you set the WeldConstraint.Part0 to its own Part? (Aka PlayerInfoPart)

And hm it prints nil the moment the clone gets parented & created, try setting its properties first before parenting it to the workspace?

1 Like

I first set the properties before I printed it. The Part0 Is the Hitbox so yes.
This is how it looks like when I have a blocky avatar. Like I said when I’m blocky everything is fine.
image
But when I have custom bodyparts it doesn’t even clone the hitbox. I then added a wait(5) and it worked. Is there a way to detect if the character is FULLY loaded? And why is this even the case? Shouldn’t the player.CharacterAdded() event be enough?

It could be due to how your custom bodyparts are being handled? What does it look like & what parts are there?

This is how it looks like when I have custom body parts. (The PlayerInfoPart is inside because I added the wait(5) to the script

Try using .CharacterAppearanceLoaded rather than .CharacterAdded

3 Likes

Using .CharacterAppearanceLoaded rather than .CharacterAdded actually worked, thanks.