Attatchment Position Moving Weirdly

Its kinda hard to explain it but this video will basically show it.

I’ve spent about 30 minutes just looking through this and I haven’t been able to find anything. This usually starts to happen when I start moving my character.

function LaserRenderer.createLaser(toolHandle, endPosition)
	local startPosition = toolHandle.Position

	local laserDistance = (startPosition - endPosition).Magnitude
	local laserCFrame = CFrame.lookAt(startPosition, endPosition) * CFrame.new(0, 0, -laserDistance / 2)
	
	local Attatch1 = Instance.new("Attachment", toolHandle.Parent.Parent.HumanoidRootPart)
	Attatch1.Visible = true
	Attatch1.WorldPosition = startPosition
	local Attatch2 = Instance.new("Attachment", toolHandle.Parent.Parent.HumanoidRootPart)
	Attatch2.Visible = true
	Attatch2.WorldPosition = endPosition
	local laserPart = game.ReplicatedStorage.BulletTrace:Clone()
	laserPart.Parent = game.Workspace
	
	Attatch1.Position = startPosition
	Attatch2.Position = endPosition
	
	laserPart.Attachment0 = Attatch1
	laserPart.Attachment1 = Attatch2
	
	print(Attatch2.Position)
	
	local sparkeffect = game.ReplicatedStorage.EffectPart:Clone()
	sparkeffect.Parent = game.Workspace
	sparkeffect.Position = endPosition
	
	-- Add laser beam to the Debris service to be removed & cleaned up
	game.Debris:AddItem(laserPart, SHOT_DURATION)
	game.Debris:AddItem(sparkeffect, HIT_FX_DURATION)
	game.Debris:AddItem(Attatch1, SHOT_DURATION)
	game.Debris:AddItem(Attatch2, SHOT_DURATION)

	-- Play the weapon's shooting sound
	local shootingSound = toolHandle:FindFirstChild("Activate")
	if shootingSound then
		shootingSound:Play()
	end
end

return LaserRenderer

It may be a problem with the actual space its in, try converting all the WorldPosition to just Position for the attachment

So just change the worldposition to just be like Attatch1.Position = startPosition?

your creating it with a position relative to the world then your changing it into object space, change those to world position

image

1 Like

Oh those, thank you it works now!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.