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

How do I access the Z value of a part?

Asked by 7 years ago

I am trying to make a script that adds a part on top of an existing part, but I am trying to access the Z value of the existing part, so I tried this

PartZ = game.Workspace.Part.Position.Vector3.Z
print (PartZ)

Before that I tried this

PartZ = game.Workspace.Part.Position.Z
print(PartZ)

None of them worked. If anyone could explain that to me it would be gr8 m8.

2
The second one works. The first one, of course, does not. BlueTaslem 18071 — 7y
1
The second script is correct. Perci1 4988 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

The first script would not work because of the 'Vector3', this is used when trying to set a Position value such as

game.Workspace.Part.Position = Vector3.new(X,Y,Z)

Your second attempt at this should work perfectly but I advise you make it

print(tostring(PartZ))

rather than

print(PartZ)

Just to make the value a string value (I know it is not required but it is a good habit to get into for numerical values)

0
Thanks MatiasSicarius 45 — 7y
Ad

Answer this question