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

How can I use a BodyGyro to make a bot face you?

Normally I would just set the CFrame in a while loop.

while wait() do
	local direction = (plr.Character.Torso.Position - bot.Torso.Position) * Vector3.new(1, 0, 1)
	bot.Torso.CFrame = CFrame.new(bot.Torso.Position, bot.Torso.Position + direction)
end

But I want to decrease lag, so I started trying to use a body gyro.

local gyro = Instance.new("BodyGyro",bot.Torso)
gyro.D = 0
gyro.P = 9999
gyro.cframe = plr.Character.Torso.CFrame

Unfortunately it doesn't work at all -- the bot doesn't rotate. AutoRotate is disabled. Nothing is erroring in the output.

All variables are defined.

4 comments

0

A math.abs ALMOST run's like a BodyGyro's cframe.. I would go to the wiki can look up math.abs

0

math.abs is just the absolute value. How will that help me?

0

math.abs has the same value's as a BodyGyro CFrame.

0

math.abs(x) just returns the absolute value of x. Please explain how this can help me and how I can use it.

1 answer

This is probably inefficient but it should work. If it does not work it is most likely due to welds or anchoring.

while wait(0) do
	gyro.cframe = CFrame.new(bot.Torso.Position,plr.Character.Torso.Position) - bot.Torso.Position
end

1 comment

0

Unfortunately I wanted to get rid of while loops. Otherwise I would just use my first code block.

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