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

Can I do math with coordinates?

Asked by
Miike0 6
7 years ago
Edited 7 years ago

I want to make an object appear with z coordinates 2 units higher than x part. I tried to subtract from a random x coordinate using print in the command bar, but it didn't want to work. I'm probably not doing it correctly either. Thanks.

This is what I have so far:

game.ServerStorage.LargeBlueSlidePart.Parent = game.Workspace game.Workspace.LargeBlueSlidePart.Position = game.Workspace.Part.Position game.Workspace.Part:Destroy()

1
Show us what you tried in a script, please. OldPalHappy 1477 — 7y
1
this is super easy, a.Position = b.Position + Vector3.new(0, 0, 2) Perci1 4988 — 7y
0
I posted what I have so far.. How would I apply this to what I have if I'm referring to another part's position. Miike0 6 — 7y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

Remember to format your code in lua code block. It makes it easier for us to help you.

If you want to add or subtract Position, just make sure you're doing so with a corresponding datatype. The Position property returns a Vector3, so you need to excecute your math with a Vector3.

Your explanation of where the part should be, relative to the other part, didn't make much sense.. but here is an example of adding 2 studs to the z-axis.

local bluePart = game.ServerStorage.LargeBlueSlidePart;
local part = workspace.Part;

bluePart.Parent = workspace;
bluePart.Position = part.Position + Vector3.new(0,0,2);
partart:Destroy();
Ad

Answer this question