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

Body Gyro Facing Opposite Direction?

I'm working a script to were the player constantly faces in the direction of an NPC everything is working well except for the fact that instead of the character facing towards the NPC, it faces away from it. Ive tried making the X value negative to see if it changes anything but then the character just spins in circles. I'm not sure how i'm supposed to correct this?

local plr = game.Players.LocalPlayer
local char = plr["Character"]

local pos1 = char.HumanoidRootPart
local pos2 = game.Workspace.Dummy.HumanoidRootPart

local RunService = game:GetService("RunService")

local BG = Instance.new("BodyGyro", char.HumanoidRootPart)

BG.D = 150
BG.MaxTorque = Vector3.new(0, 400000, 0)
BG.P = 25000

local function onRenderStep()
	BG.CFrame = CFrame.new(pos2.Position, pos1.Position)
end

RunService.RenderStepped:Connect(onRenderStep)

1 comment

0

What are you using bodygyro for?

1 answer

✓ Accepted answer

change

BG.CFrame = CFrame.new(pos2.Position, pos1.Position)

into

BG.CFrame = CFrame.new(pos1.Position, pos2.Position)

1 comment

0

Thanks, I don’t know how I missed this.

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