Cloning Problem

Rather then cloning the hitbox, it just parents the one in the folder to the player, why is this?
This is the code where the cloning occurs:

It’s a server script

local char = NewPlayer.Character or NewPlayer.CharacterAdded:Wait()
	local hrp = char:WaitForChild("HumanoidRootPart")
	local hitbox = game.Workspace.Hitbox.Part
	local hitboxClone = hitbox:Clone()
	hitboxClone.Parent = char
	
	local weld = Instance.new("Motor6D")
	weld.Parent = hrp
	weld.Part0 = hitboxClone
	weld.Part1 = hrp
	
	wait(.001)
	
	hitboxClone.Script.Enabled = true
2 Likes

Is it because you’re declaring hitbox as “Hitbox.Part” rather than just “Hitbox”?

1 Like

I have no idea if that’s the issue, but I fixed it by just moving the hitbox folder as a child of the script, and changed my code to this:

local char = NewPlayer.Character or NewPlayer.CharacterAdded:Wait()
	local hrp = char:WaitForChild("HumanoidRootPart")
	local HitboxFold = script:WaitForChild("Hitbox")
	local hitboxClone = HitboxFold:WaitForChild("Part"):Clone()
	hitboxClone.Parent = char
	
	
	local weld = Instance.new("Motor6D")
	weld.Parent = hrp
	weld.Part0 = hitboxClone
	weld.Part1 = hrp
	
	wait(.001)
	
	hitboxClone.Script.Enabled = true
1 Like

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