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

How would I go about making a Character BodyGyro?

Asked by
Mowblow 117
9 years ago

How would I make it so a BodyGyro, placed into the Character's torso, is pointed toward where the player puts their mouse?

I am guessing it would be something like this...

You would have a localscript inside the player that has the code:

local Player = game.Players.LocalPlayer
local mouse = Player:GetMouse()
local Gyro = script.Parent:FindFirstChild("Torso"):FindFirstChild("BodyGyro")

local CanTurn = true -- A bool value that will be determined that will determine if the character is allowed to turn at this moment in time.

Gyro.Torque = Vector3.new(10000000,10000000,10000000)

if Gyro == true then
while CanTurn == true do
Gyro.cframe = Cframe.new(0,mouse.X,0)
end
end

This is meant to where the player turns their mouse, their character will turn, but they cannot turn upward, so that the fall over.

Will this work?

0
Well, Gyro will NEVER be equal to true. It would either be an object or nil. Tkdriverx 514 — 9y
0
That is incorrect, because when I call the bool function in this case, it is Gyro == true. This is checking to see if it has found the Child in FindFirstChild(). If it is true, it has found the child, if false, it has not. Mowblow 117 — 9y

Answer this question