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

Dummy facing my player, any help?

Asked by 6 years ago

I was doing some tests, trying to get this Dummy facing my character, but i only could make it facing the same direction im facing, and i want him facing the opposite (looking at me) any help?

Heres my code:

local root2 = script.Parent:WaitForChild("HumanoidRootPart")

while wait(1) do
    local root = game.Workspace.TrololoMaster42.HumanoidRootPart
    local rotation = root.CFrame - root.Position
    root2.CFrame = rotation + root2.Position
end

Heres my result: https://gyazo.com/801f7d37a6a37478f9d0d65729f12a10

0
Multiply the rotation by -1. NotInventedHere 158 — 6y
0
No result TrololoMaster42 18 — 6y

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

The second argument of CFrame.new is the position that the instance will point towards:

local root2 = script.Parent:WaitForChild("HumanoidRootPart")

while wait(1) do
    local root = workspace:WaitForChild("TrololoMaster42"):WaitForChild("HumanoidRootPart")
    local lookAt = (root.Position - root2.Position).unit * Vector3.new(1,0,1)
    root2.CFrame = CFrame.new(root2.Position,root2.Position + lookAt)
end
0
Thats exactly what i needed! Thanks! TrololoMaster42 18 — 6y
Ad

Answer this question