Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I convert code using Vector3 into code using CFrame?

I was originally using Vector3, but CFrame gives me more capabilities. Here is my code, but how do i make everything the same with the only difference be using CFrame instead of Vector3.

	script.Parent.MouseClick:Connect(function(player)
		
		
		
    	player.leaderstats.Power.Value = player.leaderstats.Power.Value + 2
	    local character = player.Character
		local part = script.Parent.Parent.Parent
		
		part:MoveTo(Vector3.new(-136.224, -74.013, -484.131))
		wait(30)
		
		part:MoveTo(Vector3.new(-136.224, -69.682, -484.131))
		

		end)

TYSM

6 comments

0

What is "part"? A model?

0

yes

0

its a model

0

I dont think a model has the function "MoveTo()" in it

0

i just want to know how to turn the vector3s into CFrames

0

MoveTo() is a function of Model.

1 answer

If you want to change the CFrame of a part, simply change it's CFrame property.

part.CFrame = CFrame.new(x , y , z)

If you want to change the CFrame of a model, use the method SetPrimaryPartCFrame.

model:SetPrimaryPartCFrame(CFrame.new(x , y , x))

As the name implies, the model needs a primary part in order to work.

What you're doing right now is calling a function called MoveTo() which is a method of Model that behaves the same way as SetPrimaryPartCFrame but uses a Vector3 instead to position.

By the way, you should also consider reading up on the differences between CFrames and Vector3s. There are use cases for both of these data types and CFrames shouldn't simply be considered a better version or be all end all of Vector3s.

This discussion is preserved as it was. New answers, comments, and votes are closed.