Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
KelcriC -1
5 years ago

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

0
What is "part"? A model? xPolarium 1388 — 5y
0
yes KelcriC -1 — 5y
0
its a model KelcriC -1 — 5y
0
I dont think a model has the function "MoveTo()" in it User#23252 26 — 5y
View all comments (2 more)
0
i just want to know how to turn the vector3s into CFrames KelcriC -1 — 5y
0
MoveTo() is a function of Model. green271 635 — 5y

1 answer

Log in to vote
0
Answered by
RayCurse 1518 Moderation Voter
5 years ago
Edited 5 years ago

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 betweenCFrames 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.

Ad

Answer this question