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

The beam meets the hand at it's center. I want it to be the end of the beam touching the hand. How?

while wait() do
		if on ~= "n" then
				beam.Size = Vector3.new(0,((hit.UpperTorso.Position - plr.Character.RightHand.Position).Magnitude)-1,0)
				local num = (hit.UpperTorso.Position - plr.Character.RightHand.Position).Magnitude
				local targetPosition = hit.UpperTorso.Position
				local pos = (plr.Character.RightHand.Position)
				beam.CFrame = CFrame.new(pos, targetPosition)
				local rotatedCFrame = CFrame.Angles(math.rad(-90), 0, 0)
				beam.CFrame = beam.CFrame:ToWorldSpace(rotatedCFrame)
			else
				beam:Destroy()
			end
		end

Currently, the beam meets the hand at its center. I want it to be the end of the beam touching the hand. How? I have tried many things.

1 answer

Replace

beam.CFrame = CFrame.new(pos, targetPosition)

with

beam.CFrame = CFrame.new((pos + targetPosition)/2, targetPosition)

3 comments

0

Doesn't work.

0

sorry i think i misunderstood the problem before. i made an edit

0

works better, just now not lining up with the hand, when the player moves, it has an offset that increases/decreases depending on direction

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