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

Trouble with making parts facing direction of player?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try doing this:

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

beam.CFrame = CFrame.new(startPosition, targetPosition)
0
ty, ill try it rn hihowareya115 53 — 4y
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. hihowareya115 53 — 4y
0
Oh, sorry. I meant to say char.HumanoidRootPart.CFrame. I've edited the original answer so it works. youtubemasterWOW 2741 — 4y
Ad

Answer this question