I'm trying to make a beam attack that when activated creates a beam in front of the player. However, when testing, the attack wasn't facing the right direction. I've tried doing beam.Orientation and beam.CFrame. Here is the script:
game.ReplicatedStorage.BeamEvent.OnServerEvent:Connect(function(player)
local char = player.Character
local beam = workspace.Beam:Clone()
local HRP = char:WaitForChild("HumanoidRootPart")
beam.Parent = workspace
beam.Position = Vector3.new(HRP.Position.X,HRP.Position.Y,HRP.Position.Z)
beam.CFrame = HRP.CFrame
end)
If there is a better way to do this with I feel like there is a better way to do this with cframe, however, I'm not so good with it.

3 comments
ty, ill try it rn
i keep getting the error "bad argument #2 (Vector3 expected, got Object)". I switched it to Vector3 to test, then it said the same thing but it expected cframe.
Oh, sorry. I meant to say char.HumanoidRootPart.CFrame. I've edited the original answer so it works.