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 CFrame relative to a part's current position?

All the wiki article says is about moving parts to a position. How about, say, moving a part 10 studs up?

1 answer

✓ Accepted answer

It's as simple as this:

(Example script) - This would move the part relative to another parts location:

Part1=script.Parent
Part2=game.Workspace.Part2
Part1.CFrame=CFrame.new(Part2.Position.X,Part2.Position.Y+10,Part2.Position.Z) --This would move "Part1"  exactly 10 studs above "Part2".

(Example script 2) - This would move the part relative to its location

Part1=script.Parent
Part1.CFrame=CFrame.new(Part.Position.X,Part.Position.Y+10,Part.Position.Z) --This would move it exactly 10 studs above it's previous location.

So basically, you just use Position.X , Position.Y , and Position.Z to get the Parts positions, then you subtract or add to get it to where you want. Anyways, if you have any questions, please leave a comment below. Hope this helped :P

2 comments

1

Inefficient. You can simply multiply a CFrame by another CFrame which is "adding" them together. It will return the combined CFrame

0

He's not an expert scripter, don't worry about efficiency. He's learning the basics, so it doesn't really matter.

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