Model not spawning in correct position

detector.Touched:Connect(function(part)
	if part.Name == "Fabric" and part:HasTag("Unprocessed") then
		part:RemoveTag("Unprocessed")
		Activated()
		local rng = math.random(1, 2)
		print("RNG")
		if rng == 1 then
			local shirt: Model = game.ServerStorage.Shirt:Clone()
			for _, v in shirt:GetChildren() do
				v.Color = part.Color
			end
			shirt.PrimaryPart.CFrame = CFrame.new(part.Position, part.Orientation)
			part:Destroy()
			shirt.Parent = workspace
		else
			local pants: Model = game.ServerStorage.Pants:Clone()
			for _, v in pants:GetChildren() do
				v.Color = part.Color
			end
			if pants.PrimaryPart == nil then
				print("No primary part")
			end
			pants.PrimaryPart.CFrame = CFrame.new(part.Position, part.Orientation)
			part:Destroy()
			pants.Parent = workspace
		end
	else
		print("Not Fabric")
	end
end)

This script basically gets a part that touches something, then turns it into either a shirt or pants. However, the shirts spawn fine and replicate position and orentation of the part, but the pants spawn in but don’t copy the position or orentiation (they just spawn in their og position from serverstorage)

Try it;

local orientation = part.Orientation
targetModel.PrimaryPart.CFrame = CFrame.new(part.Position) * CFrame.fromOrientation(
	orientation.X,
	orientation.Y,
	orientation.Z
)

Instead of;

Reasons;
1 - CFrame.new(pos: Vector3, lookAt: Vector3) is deprecated as i know, you need use CFrame.lookAt but is not a problem skip that.

2 - You can’t simulate part’s orientation with lookAt parameter it’s just make part look at the specified position not orientation.

The pants are still not working. It’s werid because the shirts work and they are the exact same script. The pants have a primary part, and the model is structured exactly like the shirt.

How can i find a solution to it without a place link or video?

image_2024-08-30_165043151

Can you check weld’s and send a part from code?

welds are fine. confused on what you mean “part from code”

how do you expect me to fix something I haven’t seen?

im asking what you are even referring to. I have no idea what you mean “part from code”

A screenshot or code from where you changing pant’s primarypart position in your script

Issue solved, apparently you need to take it to workspace first before affecting its positions.

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