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

I cant figure out how to change the position of a part in my script?

Asked by 4 years ago

Any help on this?

This is my current code

local LiftGate = game.ReplicatedStorage.LifeGate
local Gate = game.Workspace.Gate

Gate.CFrame =  CFrame.new(Vector3.new(109.869, 10.812, -86.569))
wait(3)
Gate.CFrame =  CFrame.new(Vector3.new(109.869, 8.267, -86.428))

if someone can please help with this? respond! thanks

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Alright, so what you are doing wrong is you're passing a Vector3 through a CFrame. You cannot do this.

So why can you not do this? CFrame and Vector3 are two different values, one being local and having 12 constructors (CFrame) and the other being global and only having three constructors (Vector3). You cannot pass a Vector3 value through a CFrame and vise versa; however, you can multiply and divide them.

PROPER EXECUTION:

local LiftGate = game.ReplicatedStorage.LifeGate
local Gate = game.Workspace.Gate

Gate.CFrame =  CFrame.new(109.869, 10.812, -86.569)
wait(3)
Gate.CFrame =  CFrame.new(109.869, 8.267, -86.428)

OR

local LiftGate = game.ReplicatedStorage.LifeGate
local Gate = game.Workspace.Gate

Gate.Position=  Vector3.new(109.869, 10.812, -86.569)
wait(3)
Gate.Position=  Vector3.new(109.869, 8.267, -86.428)

As I mentioned before, CFrame has 12 constructors, but you only have to pass 3 for it to execute.

I hope this helped!

Ad

Answer this question