Assigning variables to Vector3 values

After years of using Javascript, I recently tried to code using Lua so I could create Roblox games. During this transition, I’ve been able to bring many ideas and concepts from Javascript to Lua effortlessly but I recently came across a problem that should seem to work. Assigning variables to Vector3 values.

local part = game.Workspace.Part

local partX = 50
part.Position = Vector3.new(partX, 0, 0)

Above is a simple set of code that, to my understanding, should substitute the X value of the Vector3 with the value of partX (which is 50). Every time I run the game the part is in the same position prior to the code running as if it did nothing at all. No errors occur in the output.

I understand that there are many different ways for the program to carry out this action, but I’m curious as to whether or not this specific method works in Lua.

Did I do something wrong here? Or is this just not a thing in Lua?

When in doubt

print("hello world")

Yeah be aware where the script is running, where did you put the script? Is it a local script or a server script? There are certain rules for that especially for a local script in order to run.

Otherwise the code seems A ok.

The script was in a local script in the StarterGui. I see my mistake now. I initially put it there because I was trying to do this same thing with a Gui’s position (Using UDim2) and found that it didn’t work. Because it didn’t work, I did it to a part so I could see how it worked on a far more basic level. Because I didn’t take into consideration what type and where the script was located I saw that it didn’t work on the part either (and I made this thread).

Thank you for your reply.