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

How do I access the Z value of a part?

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 comments

2

The second one works. The first one, of course, does not.

1

The second script is correct.

1 answer

✓ Accepted answer

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)

1 comment

0

Thanks

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