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

Can I do math with coordinates?

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()

3 comments

1

Show us what you tried in a script, please.

1

this is super easy, a.Position = b.Position + Vector3.new(0, 0, 2)

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.

1 answer

✓ Accepted answer

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();

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