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

Trouble with making parts facing direction of player?

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.

1 answer

Try doing this:

local targetPosition = char.HumanoidRootPart.CFrame
local startPosition = beam.Position

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

3 comments

0

ty, ill try it rn

0

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.

0

Oh, sorry. I meant to say char.HumanoidRootPart.CFrame. I've edited the original answer so it works.

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