CFrame not working

Hello everyone! (This is a topic that kinda goes with my last) Basically, I’m using CFrame to make a broom go back and fourth so someone can sit on it and it takes the person to the next stage (I’m making an obby) For some ODD reason, when I position it and everything. My broom flies outside of the fricking map and goes no where near my picked position, it also turns without me doing anything to it for some reason. Here is my script.

local TweenService = game:GetService("TweenService")

local part = script.Parent

local info = TweenInfo.new(4,Enum.EasingStyle.Back,Enum.EasingDirection.Out)

local properties = {CFrame = CFrame.new(part.CFrame.Position + Vector3.new(555.698, -156.292, -761.651))}
local prop = {CFrame = CFrame.new(part.CFrame.Position + Vector3.new(409.693, -133.447, -754.564))}

local tween = TweenService:Create(part,info,properties)
local Tween = TweenService:Create(part,info,prop)

while true do
	wait(2)
	tween:Play()
	wait(5)
	Tween:Play()
	wait(5)
end

If anyone knows how to fix this, please let me know. Thanks! :)))

You are taking the broom’s Position “part.CFrame.Position” and adding “+ Vector3.new(555.698, -156.292, -761.651)” to that Position.

So would be better to do

CFrame = CFrame.new(--info inside)

because last time I did that, it worked, but the broom turned instead of looking at it’s original state.

Have you looked at how CFrames work on developer.Roblox.com?

Completed must be used for proper synchronization. This may be the problem

while true do
	wait(2)
	tween:Play()
	tween.Completed:Wait()
	wait(2)
	Tween:Play()
	Tween.Completed:Wait()
end

if the vectors Vector3.new(555.698, -156.292, -761.651) and Vector3.new(409.693, -133.447, -754.564) are the exact places where you want the part to be, then you should just do this

local properties = {CFrame = CFrame.new(555.698, -156.292, -761.651)}
local prop = {CFrame = CFrame.new(409.693, -133.447, -754.564)}

to maintain the original rotation you must add this (this could fix the rotation problem you described)

local properties = {CFrame = CFrame.new(555.698, -156.292, -761.651)*(part.CFrame - part.Position)} 
local prop = {CFrame = CFrame.new(409.693, -133.447, -754.564)*(part.CFrame - part.Position)}

Try this :

local properties = {properties.CFrame = CFrame.new(part.CFrame.Position + Vector3.new(555.698, -156.292, -761.651))}

local prop = {prop.CFrame = CFrame.new(part.CFrame.Position + Vector3.new(409.693, -133.447, -754.564))}

Basically, when you use CFrame, you need to do: (object you want to change the CFrame).CFrame = CFrame.new(…)
Also, I’m not sure if you need to use the {}, so if what after what I just sayed doesn’t work, keep what I told and remove the {}

1 Like

It is being added a {} because it is going to be the argument being sent to TweenService:Create(), which is, what Properties will be changed.

Ayyyyyyy, TYSM! It worked :)))) I’ve been trying to figure this out for a while. Sorry for the late response :)))