Why doesn't the script make the part go up?

Hello!

I wrote a script that, in fact, should raise a part by a specified number of studs up, but this does not happen…

Please, I would like to know the reason for the dysfunction of my script and how can I make it work?

(Moreover, in the output, as in the script writing mode itself, no errors are reported)

And now, perhaps, let me introduce you to the culprit of this topic:

local Part = game.Workspace.Part
Part.Anchored = true
wait(6)
local up = 4
local P = Part.Position
P = Vector3.new(
P.X,
P.Y + up,
P.Z)

I would try just doing

local Part = game.Workspace.Part
Part.Anchored = true
wait(6)
local up = 4
Part.Position += Vector3.new(0,up,0)
1 Like

Magnifico! I will definitely try your way.

What your current code is doing is setting the variable “P” equal to whatever the current position of the part. Basically say the part’s position was Vector3.new(0,0,0), the variable “P” is just going to be Vector3.new(0,0,0)

1 Like

So you mean that a variable cannot be named with the letter P?

No the variable name has nothing to do with it. The problem is that when you say:

local P = part.Position

You think that you are making the variable P the position, but you are really saying:

local P = Vector3.new() --position of the part
1 Like

I’m sorry SkyKurr, but I need to write a script so that the P variable remains.

Why? There is no way to make a variable the position, you can only change the position using

Part.Position = ....
1 Like

That is, I can save the P variable in my script, but at the same time should not inject the Position inside it? So then I’ll just write like this:

local P = Part
P.Position = Vector3.new(
P.Position.X,
P.Position.Y + up,
P.Position.Z)

And it works!

1 Like