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

Can't set a part's position?

Asked by 5 years ago

Hello,

I want to move a part in the workspace using .Position but it doesn't seem to work, here is the script:

part = game.Workspace.Part
while wait() do
part.Position = part.Position + 0, 1, 0
end

It drops an error!

Please help!

3 answers

Log in to vote
1
Answered by 5 years ago

Hello there,

Your script doesn't work because you didn't use Vector3.new() to specify the position, here is the fixed script for you:

part = game.Workspace.Part
while wait() do
part.Position = part.Position + Vector3.new(0, 1, 0) --You forgot Vector3.new() 
end

Hope this helped.

Frag

Ad
Log in to vote
0
Answered by 5 years ago
part.Position = part.Position + Vector3.new(0,1,0)
Log in to vote
0
Answered by 5 years ago

A position is a Vector3 value, so you can't add or subtract numbers to it, only other Vectors. Therefore in order to offset it's position you would need to do...

part.Position = part.Position + Vector3.new(0,1,0)

Answer this question