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

moving a part relative to torso?

Soo i have an anchored part and i need it to follow the torso but with an offset in vector3 what would be the best way to do soo?

Edit: The part rotates towards a part

2 comments

0

Give me TOP3K..

0

Give me TOP3K.. i wanit it you slut.

1 answer

✓ Accepted answer

Use CFrame.


There's a whole article on CFrames, and this question has already been asked countless times.

Here's an example:

-- local script (to make things easy as an example)
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local pp = char.PrimaryPart
while not pp do -- might not be needed; tbh this looks stupid; but it'll work with R15 and R6
	wait()
	pp = char.PrimaryPart
end

local offset = Vector3.new(5,9,0) -- +5x, +9y, +0z

local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Parent = workspace

while true do
	part.CFrame = pp.CFrame*CFrame.new(offset)
	wait()
end

How it works

BlueTaslem has answered how CFrames work, and how this works, but I couldn't find his answer because there's no favorite option on ScriptingHelpers. sigh

But, to put it simply:

part1.CFrame = part1.CFrame*CFrame.new(vector3 to move it relative to part)

Good luck!

2 comments

0

The one on the wiki, and two on this site, and most that are written by smarter people are better imo. https://scriptinghelpers.org/guides/the-power-of-cframes

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