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

BodyGyro on npc?

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!

2 comments

0

What do you mean by "always looks the same way"? Do you mean that it looks towards the player once then stops?

0

Sorry for late answer, but yes actually he does, I didn't even realise that myself.

1 answer

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

1 comment

0

Thanks, but it didn't work, sorry.

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