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

How to instance part, 100 studs away of specific object?

Asked by 5 years ago

Hello, guys i need help, how to make part 100 studs away from current object, ik i can make it with instance but like, how to make it appear 100 studs away from object(part), it does not matter where object will be when i run game, part must appear 100 studs away but how to do it?

0
Please make a script before asking for help. DinozCreates 1070 — 5y

1 answer

Log in to vote
1
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

I honestly don't know why some people are downvoting questions like this. This guy isn't asking "make me a script", he just has no idea how to do it whatsoever, so he can't "post his code".

Besides, the answer is literally one line of code, but instead of a least POINTING them in the right direction, people just say "not a request site" and walk away.

Anyways back to the question. In order to make a part spawn 100 studs away from another part, you need to grab that part's position, add 100 studs to it, and set the new part's position to it.

You probably know you can get a part's position by doing part.Position

Now, to add 100 studs to it, add a Vector3 with 100 as one of the numbers to it, like this: part.Position + Vector3.new(100, 0, 0)

Then just set that as the position of the new part.

The end code should look like this:

local part = Instance.new("Part")
part.Position = workspace.OtherPart.Position + Vector3.new(100, 0, 0)
Ad

Answer this question