Trying to Place Attachment 7 Studs In Front of Player

Wow, that is amazing, thanks for trying

I don’t want to waste any more of your time, but could I ask why it needs to be inside the workspace? The only reason I could think of is you’re trying to use world position (solved by attachment.WorldPosition) for an endpoint while raycasting.

Yeah basically I just want the attachment to go to where the ray ends which is 7 studs in front of the player

So if you do have a loop, you can use just use set the attachement position inside of the humanoidrootpart to the negative magnitude between the humanoidrootpart and end point

Uh alright Ill see what I can do, thanks!

I got this to work easily, heres a video of it and my source code. I didn’t explain it the best so iI thought i’d just show you instead.
https://youtu.be/aEqpSKIsxO4

local plr = game.Players.LocalPlayer

local char = plr.Character
local hrp = char.HumanoidRootPart

local attach = Instance.new("Attachment")
attach.Visible = true
attach.Parent = hrp
local maxPos = 7

local function raycast()
	local ray = Ray.new(hrp.Position, hrp.CFrame.LookVector * maxPos)
	return workspace:FindPartOnRay(ray, char)
end


game:GetService("RunService").RenderStepped:Connect(function()
	local part,pos,surface = raycast()
	local mag = (pos - hrp.Position).Magnitude
	attach.Position = Vector3.new(0,0,-mag)
end)

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]