Hello! So I'm trying to make a top down shooter but my CharacterControls just don't seem to work. What I'm trying to do is make the character always face the mouses position. But I just doesn't seem to work. (This is taken off the roblox wiki (http://wiki.roblox.com/index.php?title=Top_Down_Action/Controls).
local player = game.Players.LocalPlayer
local gyro = nil
local mouse = player:GetMouse()
mouse.TargetFilter = game.Workspace.LevelGeometry
local runService = game:GetService('RunService')
local function onCharacterAdded(character)
local torso = character:WaitForChild('Torso')
gyro = Instance.new('BodyGyro', torso)
gyro.P = 50000
gyro.MaxTorque = Vector3.new(0, 10000, 0)
end
local function isnan(x) return x ~= x end
local function onRenderStep()
if gyro then
local mouseHit = mouse.Hit.p
if not (isnan(mouseHit.X) or isnan(mouseHit.Y) or isnan(mouseHit.Z)) then
gyro.CFrame = CFrame.new(player.Character.Torso.Position, mouseHit)
end
end
end
while not player.Character do wait() end
onCharacterAdded(player.Character)
player.CharacterAdded:connect(onCharacterAdded)
runService:BindToRenderStep('TrackMouse', Enum.RenderPriority.Input.Value, onRenderStep)

2 comments
If you solved it, delete the question.
Please don't delete this quetion. If other people encounter the same problem, they'll (hopefully) find this solution.