How to rotate this cframe?

  1. What do you want to achieve? I want to achieve to rotate this part so it faces the correct way with this cframe script

  2. What is the issue? the issue is that no matter what value i change it just wont move!!!

  3. What solutions have you tried so far? Ive looked like every where so I am making this post.

The script is below and ill add screenshots here:

Screen Shot 2021-11-11 at 6.44.00 PM

right way suppose to be (the transparent parts are the way its moves) (just ingame doesnt face right way):
Screen Shot 2021-11-11 at 6.44.36 PM

local TweenService = game:GetService("TweenService")

local mainPart = script.Parent
local goal1 = script.Parent.Parent.main1
local goal2 = script.Parent.Parent.main2

local goal1 = {}
goal1.CFrame = CFrame.new(Vector3.new(21.449, 7.698, -55.721)) * CFrame.Angles(math.rad(-90), math.rad(90), math.rad(-70))

local goal2 = {}
goal2.CFrame = CFrame.new(Vector3.new(21.449, 9.348, -43.659)) * CFrame.Angles(math.rad(-90), math.rad(90), math.rad(-115))

local tweenInfo = TweenInfo.new(2)
local tween

while true do
	tween = TweenService:Create(mainPart, tweenInfo, goal1)
	tween:Play()
	tween.Completed:Wait()
	tween = TweenService:Create(mainPart, tweenInfo, goal2)
	tween:Play()
	tween.Completed:Wait()
end
1 Like

In your code both your goal variables are being set twice for no reason

local goal1 = script.Parent.Parent.main1 -- This is never used
local goal1 = {} -- This overwrites the "main1" instance, you also don't need the "local" here

I’m not sure what you mean by the part isn’t moving, it’s position and rotation are changing in the video, but if I understand correctly they aren’t moving the way you want them to.

I would suggest setting your goal’s CFrame using the transparent part’s CFrame, that would be easiest.

local goal = {CFrame = [TargetPartHere].CFrame}
1 Like

No, what i mean by the part moving is that rotating (sorry for the mix up of words)

1 Like

Try adding 90 degrees to the final CFrame or messing around with your current angles.

1 Like

Ive tried changing the values and messing with it but nothing seems to work for me.

1 Like

I’m going to some things myself. I’ll update you what happens.

1 Like

Video

local TweenService = game:GetService("TweenService")

local model = script.Parent

while true do
	TweenService:Create(model.Main, TweenInfo.new(2), {Position = model.Goal1.Position}):Play()
	task.wait(2)
	TweenService:Create(model.Main, TweenInfo.new(2), {Position = model.Goal2.Position}):Play()
	task.wait(2)
end

Edit: Further optimized the code to be smaller.

Btw you don’t even need CFrame for this. You could just use position unless your gonna do some angle stuff later.

Like @MrLonely1221 Said you could replace the CFrame values with the two parts positions.

2 Likes

So why are you referencing the two parts and then not using them? You could just move and position those so that it goes from the CFrame of one, to the CFrame of the other.

1 Like

Thank you a lot! This works perfectly! :slight_smile: