local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character
local mouse = player:GetMouse()
local following = true
local bodyGyro = nil
function addMouseFollow(newCharacter)
character = newCharacter
bodyGyro = Instance.new("BodyGyro")
bodyGyro.P = 2000
bodyGyro.D = 10
bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
bodyGyro.Parent = character:WaitForChild("HumanoidRootPart")
character.Humanoid.AutoRotate = false
end
mouse.Move:Connect(function()
if following then
if bodyGyro then
bodyGyro.CFrame = CFrame.new(character.HumanoidRootPart.Position, Vector3.new(mouse.Hit.p.X, character.HumanoidRootPart.Position.Y, mouse.Hit.p.Z))
end
end
end)
UserInputService.InputBegan:Connect(function(input, override)
if not override then
if input.KeyCode == Enum.KeyCode.Q then
following = not following
if bodyGyro then
if not following then
bodyGyro.P = 0
character.Humanoid.AutoRotate = true
else
character.Humanoid.AutoRotate = false
bodyGyro.P = 2000
end
end
end
end
end)
player.CharacterAdded:Connect(addMouseFollow)
This topic was automatically closed after 8 minutes. New replies are no longer allowed.