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

I cannot move my part using the x,y or z axis?

Im trying to learn how to move blocks and tried this today.


local PartYes = script.Parent

while true do 
	PartYes.Position.X = 35.05
	PartYes.Position.Y = 0.6
	PartYes.Position.Z = 50.10
end

In the script it shows nothing wrong but in the output it says "X cannot be assigned", Can anyone please help me with this?

2 comments

0

Do you want to rapidly set the Position of your part to that or do you want to move it rapidly? Remember too the delay at the end!

0

Position is a Vector3. Vector3's X, Y, and Z values are readonly. Assign the Position to another Vector3 value if you want to change it. PartYes.Position = Vector3.new(35.05, 0.6, 50.10). Also, why is that inside a loop?

2 answers

Vector3's cannot be directly assigned to via their subproperties. You have to provide a direct Vector3 value to the positions. Also--add a wait() in your while true do.

while true do
	wait()
	PartYes.Position = Vector3.new(35.05, 0.6, 50.10)
end

However, you can reference the axis inside of the Vector3.

while true do
	wait()
	PartYes.Position = Vector3.new(PartYes.Position.X, 0.6, PartYes.Position.Z)
end

You can also wrap the part in order to allow the XYZ values to be written to seperately.

1 comment

0

(you can add the wait() at the end so you can ignore it easily)

If you just wan't to move YesPart then do this, This will only move YesPart only once.

local PartYes = script.Parent

PartYes.Position = PartYes.Position + Vector3.new(35.05,0,0)
PartYes.Position = PartYes.Position + Vector3.new(0,0.6,0)
PartYes.Position = PartYes.Position + Vector3.new(0,0,50.10)

or

local PartYes = script.Parent

PartYes.Position = PartYes.Position + Vector3.new(35.05,0.6,50.10)

If you want to constantly move YesPart then do this instead, This will move the YesPart every 5 second.

local PartYes = script.Parent

while true do
	PartYes.Position = PartYes.Position + Vector3.new(35.05,0,0)
	PartYes.Position = PartYes.Position + Vector3.new(0,0.6,0)
	PartYes.Position = PartYes.Position + Vector3.new(0,0,50.10)
	wait(5)
end

or

local PartYes = script.Parent

while true do
	PartYes.Position = PartYes.Position + Vector3.new(35.05,0.6,50.10)
	wait(5)
end

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