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

Body Gyro Facing Opposite Direction?

Asked by 5 years ago

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)
0
What are you using bodygyro for? Azure_Kite 885 — 5y

1 answer

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

change

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

into

BG.CFrame = CFrame.new(pos1.Position, pos2.Position)
0
Thanks, I don’t know how I missed this. Revisedy 23 — 5y
Ad

Answer this question