Repeated Rotation before Reposition failing

  1. What do you want to achieve? Keep it simple and clear!
  • A function which rotates a model before moving the entire model to a point where the entrancePart is directly inside the exitPart of the previous model.
  1. What is the issue? Include screenshots / videos if possible!
  • Rotating it before moving it does nothing, as the CFrame.new resets the rotation
  • Rotating it before alongside setting a new Pivot and Difference causes the 2nd+ time to
  1. move the position incorrectly(the red arrow in the picture)
  2. not rotate(The second problem ill try to figure out on my own). (Solved) (Pretend image doesn’t want it to repeatedly rotate)
    3.the first rotation is incorrect, rotating only 30.4~ degrees.(Solved)
  • Rotating afterwards positions the entrancePart incorrectly
  • Rotating it in the same line of code as moving it causes the same problems as another attempt.
  • Using SetPrimaryPartCFrame changes nothing
  • I also tried printing out every little thing; the information only turned my brain into zombie smoothie
    Did you look for solutions on the Developer Hub?
  • I haven’t seen anybody with the same problems as me, or I just cant understand their code.

The code has been slightly edited to remove my uh… giberish.

local repStorage = game.ReplicatedStorage

	function makeModel(x, y, z) -- xyz's are obtained through the previous model's exitPart
	    print("I need help")
	    local selectedModel = math.random(1, 2)
	    local clonedModel= repStorage :FindFirstChild(selectedModel ):Clone() --I randomize the cloned model between 2 different models labelled "1" and "2"
	    clonedModel.PrimaryPart = clonedModel:FindFirstChild("exitPart")
	    local pivot = clonedModel:GetPivot()
	    clonedModel.Parent = workspace
	    local Direction = script.DirectionV.Value --Direction = 100, its a Value under the module script
	    local entrancePosition = clonedModel:FindFirstChild("Entrance").Position
	    local difference = Vector3.new(x ,y ,z ) - entrancePosition 
	    clonedModel:PivotTo(pivot * CFrame.Angles(0, Direction, 0) * CFrame.new(difference)) 
	    print(difference)
	end

return {
	makeModel = makeModel
}

Example Picture

CFrame.Angles uses radians so i think you should use math.rad() to convert 100 degrees to radians.

1 Like

have you tried using CFrame.Rotation on the old model to get the rotation and storing it to use on the new one?

1 Like

Ah, I see! I’ll edit the code later to include the previous parts rotation.

1 Like

I forgot to re-add the math.rad, ill fix that right now.

1 Like