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.
Try doing this:
local targetPosition = char.HumanoidRootPart.CFrame local startPosition = beam.Position beam.CFrame = CFrame.new(startPosition, targetPosition)