Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago
Edited 3 years ago
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

Log in to vote
0
Answered by
Luathron 185
3 years ago
Edited 3 years ago

Replace

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

with

beam.CFrame = CFrame.new((pos + targetPosition)/2, targetPosition)
0
Doesn't work. NeonNikilis 5 — 3y
0
sorry i think i misunderstood the problem before. i made an edit Luathron 185 — 3y
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 NeonNikilis 5 — 3y
Ad

Answer this question