So i am trying to rotate the players body to face the mouse with this: INSIDE “STARTERPLAYERSCRIPT” IN LOCAL SCRIPT
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
tor = character:WaitForChild("UpperTorso")
hum = character:WaitForChild("Humanoid")
end
local cam = game.Workspace.CurrentCamera
local equipped = false
local tor = character.UpperTorso
local hum = character.Humanoid
player.CharacterAdded:Connect(function()
character = player.Character
tor = character:WaitForChild("UpperTorso")
hum = character:WaitForChild("Humanoid")
end)
local Mouse = player:GetMouse()
local prev_mousehit
game:GetService("RunService").RenderStepped:Connect(function()
if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
hum.AutoRotate = false
if Mouse.Hit.p ~= prev_mousehit then
tor.CFrame = CFrame.new(tor.Position, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
prev_mousehit = Mouse.Hit.p
end
else
hum.AutoRotate = true
end
end)
The result is funny but not the result you’d expect.
I would imagine the solution is unlocking whatever joint is locked but what do i know?
Also in first person it flat out doesn’t work.
Try rotating the players Motor6D joint instead of their body part.
example code:
local waist = player.Character.UpperTorso.Waist
waist.C0 = CFrame.new(waist.C0.p, camera.CFrame.lookVector)
your rotating the UpperTorso directly, and it is welded to other BodyParts with Motor6D joints
so this is making the entire model move along with the UpperTorso.
But rotating the Motor6D instead should solve your issue.
I might make a fool of myself here but did you mean like this? character:WaitForChild("UpperTorso").Waist
whole code:
local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
tor = character:WaitForChild("UpperTorso").Waist
hum = character:WaitForChild("Humanoid")
end
local cam = game.Workspace.CurrentCamera
local equipped = false
local tor = character.UpperTorso.Waist
local hum = character.Humanoid
player.CharacterAdded:Connect(function()
character = player.Character
tor = character:WaitForChild("UpperTorso").Waist
hum = character:WaitForChild("Humanoid")
end)
local Mouse = player:GetMouse()
local prev_mousehit
game:GetService("RunService").RenderStepped:Connect(function()
if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
hum.AutoRotate = false
if Mouse.Hit.p ~= prev_mousehit then
tor.CFrame = CFrame.new(tor.Position, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
prev_mousehit = Mouse.Hit.p
end
else
hum.AutoRotate = true
end
end)
Try this, you might have to do some fine tuning, and instead of using mouse hit you could use cameras LookVector, also you’ll probably want to mix this up with waist and head movement, but i’m not fully sure of your end goal here.
local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
tor = character:WaitForChild("UpperTorso").Waist
hum = character:WaitForChild("Humanoid")
end
local cam = game.Workspace.CurrentCamera
local equipped = false
local waist
local hum
player.CharacterAdded:Connect(function()
character = player.Character
waist = character:WaitForChild("UpperTorso"):WaitForChild("Waist")
hum = character:WaitForChild("Humanoid")
end)
local Mouse = player:GetMouse()
local prev_mousehit
game:GetService("RunService").RenderStepped:Connect(function()
if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
hum.AutoRotate = false
if Mouse.Hit.p ~= prev_mousehit then
waist.C0 = CFrame.new(waist.C0.p, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
prev_mousehit = Mouse.Hit.p
end
else
hum.AutoRotate = true
end
end)
btw End goal: the head and body moves with the camera / mouse and it allows for more combat options for guns and swords and stuff. sou can slash up/down/left/right not just left/right
Guess who’s back.
it is still nil and i can’t figure out why?
player = game.Players.LocalPlayer
function onCharacterAdded()
local character = player.Character
if not character or not character.Parent then
character = player.CharacterAdded:wait()
tor = character:WaitForChild("UpperTorso").Waist
hum = character:WaitForChild("Humanoid")
end
local cam = game.Workspace.CurrentCamera
local equipped = false
local waist
local hum
player.CharacterAdded:Connect(function()
character = player.Character
waist = character:WaitForChild("UpperTorso"):WaitForChild("Waist")
hum = character:WaitForChild("Humanoid")
end)
local Mouse = player:GetMouse()
local prev_mousehit
game:GetService("RunService").RenderStepped:Connect(function()
if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
hum.AutoRotate = false
if Mouse.Hit.p ~= prev_mousehit then
waist.C0 = CFrame.new(waist.C0.p, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
prev_mousehit = Mouse.Hit.p
end
else
hum.AutoRotate = true
end
end)
end
player.CharacterAdded:Connect(onCharacterAdded)
fixed a thing but still the errors… the errors @codyorr4
local player = game.Players.LocalPlayer
local character
local waist
local hum
local cam = game.Workspace.CurrentCamera
local equipped = false
local Mouse = player:GetMouse()
local prev_mousehit
function onCharacterAdded()
character = player.Character
waist = character:WaitForChild("UpperTorso"):WaitForChild("Waist")
hum = character:WaitForChild("Humanoid")
game:GetService("RunService").RenderStepped:Connect(function()
if (cam.Focus.p-cam.CoordinateFrame.p).magnitude > 1 then
hum.AutoRotate = false
if Mouse.Hit.p ~= prev_mousehit then
waist.C0 = CFrame.new(waist.C0.p, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
prev_mousehit = Mouse.Hit.p
end
else
hum.AutoRotate = true
end
end)
end
player.CharacterAdded:Connect(onCharacterAdded)
@UltimateRaheem waist.C0 = CFrame.new(waist.C0.p, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z))
fix it as shown: waist.C0 = CFrame.new(waist.C0.p, Vector3.new(Mouse.Hit.p.x,Mouse.Hit.p.y,Mouse.Hit.p.z-90))
@codyorr4
but it works… although when the mouse is behind the character he breaks his spine and won’t turn anaud with his lower body… i can thy to fix it
yeah like i said it will need some fine tuning (and to be clamped) also its probably best to use camera LookVector rather then mouse.Hit, depending on what you need i suppose, but yeah haha that’s pretty funny looking.