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

How can i make a beam that comes from the player's hand?

How can I make a beam that comes from the player's hand?

Pretty much it, I can't seem to figure out how to make a beam come from the players hand

2 comments

0

Learn about tools

0

Without tools :/

1 answer

✓ Accepted answer

I’m entirely clueless if this code will perform the action you desire, as I did my best to visualize the scenario and tried to apply some snippets from trajectory calculations with integrated Raycast data—from a firearm.

local Debris = game:GetService("Debris")

local Player = game:GetService("Players").LocalPlayer
local Cursor = Player:GetMouse()

local function DrawBeam(StartPos, EndPos)
    local Beam = Instance.new("Part")
    Beam.Name = "Beam"
   
    Beam.Material = Enum.Material.Neon
    Beam.CanCollide, Beam.Anchored = false, true
    Beam.BrickColor = BrickColor.Red()
   
    Beam.Size = Vector3.new(.3,.3,EndPos)
    Beam.CFrame = CFrame.new(StartPos, EndPos) * Cframe.new(0,0,-EndPos/2)

    return Beam
end

Cursor.Button1Down:Connect(function()
    local Character = Player.Character or Player.CharacterAdded:Wait()
    local RightHand = Character:WaitForChild("RightArm")
    local ToClickPosition = (RightHand.Position - Cursor.Hit.p).magnitude
    local Beam = DrawBram(RightHand.Position, ToClickPosition)
    Beam.Parent = workspace
    Debris:AddItem(Beam, 1)
end)

1 comment

0

Thank you, this gave me a pretty good example on how to do it. and I managed to figure it how.

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