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

moving a part relative to torso?

Asked by
Filipalla 504 Moderation Voter
6 years ago
Edited 6 years ago

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

0
Give me TOP3K.. IMATROLLERHEREAHH -5 — 6y
0
Give me TOP3K.. i wanit it you slut. IMATROLLERHEREAHH -5 — 6y

1 answer

Log in to vote
0
Answered by
CootKitty 311 Moderation Voter
6 years ago
Edited 6 years ago

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!

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 CootKitty 311 — 6y
Ad

Answer this question