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

BodyGyro on npc?

Asked by 8 years ago

i tried making a npc that would look at you during combat, but he always looks the same way, I used BydoGyro and this is how the script works;?

q = script.Parent:findFirstChild("BodyGyro")
    if q then
    else
        z = Instance.new("BodyGyro")
        z.Parent = script.Parent
        z.maxTorque = Vector3.new(40000,1,40000)
        z.P = 40000
        z.D = 5000
        z.cframe = CFrame.new(script.Parent.Position,Part.Parent.Torso.Position)
    end

any tips/help is appreciated! Thanks!

0
What do you mean by "always looks the same way"? Do you mean that it looks towards the player once then stops? Spongocardo 1991 — 8y
0
Sorry for late answer, but yes actually he does, I didn't even realise that myself. jimmie9999 10 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Try this, I'm not sure if it'll work, basically it gets the looking direction of the player and inverts it so that the NPC will hopefully face the player. Please let me know if this does NOT work, give a rep and mark as answered if this works! Thanks!

q = script.Parent:findFirstChild("BodyGyro")
    if q then
    else
        z = Instance.new("BodyGyro")
        z.Parent = script.Parent
        z.maxTorque = Vector3.new(40000,1,40000)
        z.P = 40000
        z.D = 5000
        z.cframe = CFrame.new(CFrame:inverse(CFrame.lookVector(script.Parent.Position,Part.Parent.Torso.Position)))
    end

0
Thanks, but it didn't work, sorry. jimmie9999 10 — 8y
Ad

Answer this question