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

How can you attach a brick to a player?

Here is what I have so far:

local part = Instance.new("Part")
part.Parent = character.HumanoidRootPart.Parent
part.CanCollide = false
part.BrickColor = BrickColor.new("Really blue")

part.CustomPhysicalProperties = PhysicalProperties.new(0,0,0)

part.CFrame = character.HumanoidRootPart.CFrame
wait()
local w = Instance.new("Weld", part)
w.C0 = character.HumanoidRootPart.CFrame
w.Part0 = part
w.Part1 = character.HumanoidRootPart

Currently it attaches to the player but not at the HumanoidRootPart however its further apart can't figure out whats going on thanks for your help

Gif: https://gyazo.com/78e02d9801691ccf836c5ff864d17bb6

2 answers

✓ Accepted answer

The problem is here

w.C0 = character.HumanoidRootPart.CFrame

C0 is a relative CFrame so if your character.HumanoidRootPart.CFrame == CFrame.new(5,0,20) then the part is going to attach itself 5 studs x and 20 studs z of your humanoid part. If you want the part to be exactly at the same spot as your humanoid root part then do

w.C0 = CFrame.new(0,0,0)

2 comments

0

Thanks justoboy13 that makes a lot of sense to me, much appreciated

0

No problem. Most people try to explain how to do it but not give you the code, but i find it easier to learn something with a good example so i give people the code they need and explain how it works.

set up a loop:

local part = Instance.new("Part")
part.Parent = character.HumanoidRootPart.Parent
part.CanCollide = false
part.BrickColor = BrickColor.new("Really blue")

part.CustomPhysicalProperties = PhysicalProperties.new(0,0,0)
wait()
local w = Instance.new("Weld", part)
w.C0 = character.HumanoidRootPart.CFrame
w.Part0 = part
w.Part1 = character.HumanoidRootPart

while wait() do
	part.CFrame = character.HumanoidRootPart.CFrame
end

line 13-15 does that for you, it makes a loop which u can use to make the part go on you

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