Trying to Place Attachment 7 Studs In Front of Player

Wait this might work I have a question what is the surface part of the raycast?

The surface normal gives you the direction of the face of the object you hit. Like how bullet holes are rendered with raycasting, laying flat against walls.

Ohhhhh, Interesting ill have to make use of that eventually, alright well I tried the -mag thing and I have no idea where the attachments are now

function FindWall()
	local climbRay = Ray.new(humrp.Position, humrp.CFrame.lookVector * 7)
	local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(climbRay, {humrp})
	if hit and not Climbing then
		local mag = (position - humrp.Position).Magnitude
--		CAS:BindAction("Up", W, false, "w")
--		CAS:BindAction("Down", S, false, "s")
--		CAS:BindAction("Left", A, false, "a")
--		CAS:BindAction("Right", D, false, "d")
		local attachment = Instance.new("Attachment")
		attachment.WorldPosition = Vector3.new(0,0,-mag)
		attachment.Visible = true
		attachment.Name = "WallClimb"
		attachment.Parent = hit
	end
end

?

Oh, don’t set the world position unless you’re still keeping it in workspace. After thinking about it if you do wanna keep it in workspace you should just be able to do Attachment.WorldPosition = (humrp.CFrame * CFrame.new(0,0,-mag)).p

Hey there, what I was saying is that you don’t need to use a lookvector on the attachments “cframe” to accomplish this.

What is the .p at the end of all that mean?

The .p gives us the worldposition or vector3 of the cframes. It is deprecated for .Position, but it’s usually not looked down upon.

This is what I got in the output

Uh, Could you post line 36 for me?

bet my guy

Probably a weird way but this is what I’d do

local attachment = Instance.new("Attachment")
attachment.CFrame = humrp.CFrame + (humrp.CFrame.lookVector * 7)

You forgot a comma before -mag

Oh yea I did thanks!
[30 Characters]

Hmm, Hidden it still doesnt seem to be working at all

image

Ill try that right now megu thanks!

Btw, could I ask why you’re parenting it to the object? I don’t really see a point in this.

Check the axis the attachment is being placed on. Is it on the (blue) Z axis? Your part may not be faced the way you want it to be for it to go forward.

(for when you tried my code)

You can alternatively replace this code here:

CFrame.new(0, 0, -(humrp.Size.Z/2 + offset))

With the following:

CFrame.new(0, 0, humrp.Size.Z/2 + offset)

Or:

CFrame.new(-(humrp.Size.X/2 + offset), 0, 0)

Or:

CFrame.new(humrp.Size.X/2 + offset, 0, 0)

EDIT: Attachments are required to be parented to an object because their position/CFrame is based off their parent.

Well, I can’t parent it into workspace because attachments cant parent into workspace, only the parts in workspace and when I raycast I want the parent of the attachment since that attachment is going to be on the wall the ray finished at, it only makes sense to attach it to the wall.

Tried those and all of them put the attachments behind where the part is and in different places depending on where my player is