I’ve been stuck trying to find how would I be able to make the player rotate up and down and left to right, but when I try to do both at the same time it just does the first axis.
local tool = script.Parent
local Player = game:GetService("Players").LocalPlayer
local c = Player.Character or Player.CharacterAdded:Wait()
local hrp, hum = c:WaitForChild("HumanoidRootPart"), c:WaitForChild("Humanoid")
local rs = game:GetService("RunService")
local Holding = false
local mouse = Player:GetMouse()
local function FaceMouse()
local bp = Instance.new("BodyPosition")
bp.MaxForce = Vector3.new(900000, 900000, 900000)
bp.P = 7000
bp.D = 500
bp.Position = hrp.Position
bp.Parent = hrp
local bg = Instance.new("BodyGyro")
bg.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
bg.P = 9000
bg.D = 50
bg.CFrame = CFrame.new(hrp.Position, CFrame.new(mouse.hit.p.X, hrp.Position.Y, mouse.hit.p.Z).p)
bg.Parent = hrp
return bp, bg
end
tool.Activated:Connect(function()
local bp, bg = FaceMouse()
local cur = tick()
repeat
bg.CFrame = CFrame.new(hrp.Position, CFrame.new(mouse.hit.p.X, hrp.Position.Y, mouse.hit.p.Z).p)
rs.Heartbeat:Wait()
until (tick() - cur) >= 5
bp:Destroy()
bg:Destroy()
end)
This is what I have so far I want the hrp position to move with the X and Y of the mouse.
local tool = script.Parent
local Mouse = game.Players.LocalPlayer:GetMouse()
local character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Humanoid = character:WaitForChild('Humanoid')
local Position = Mouse.Hit.Position
local AimState = false
tool.Activated:Connect(function()
AimState = true
game:GetService('RunService').RenderStepped:Connect(function()
if AimState == true then
local Position = Mouse.Hit.Position
character.HumanoidRootPart.Anchored = true
character.HumanoidRootPart.CFrame = CFrame.new(character.HumanoidRootPart.Position, Position)
else
character.HumanoidRootPart.Anchored = false
end
end)
task.wait(2)
AimState = false
end)