- 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.
- 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
- move the position incorrectly(the red arrow in the picture)
- 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