mouse.Icon = 'http://www.roblox.com/asset/?id=172802980'
game:GetService("StarterGui"):SetCoreGuiEnabled("Health", false)
game:GetService("StarterGui"):SetCoreGuiEnabled("Chat", false)
while game.Players.LocalPlayer.Character do
task.wait(0.)
local char = game.Players.LocalPlayer.Character
if char:FindFirstChild("Torso") and char:FindFirstChild("HumanoidRootPart") then
local Torso = char.Torso
local HumanoidRootPart = char.HumanoidRootPart
Torso.Orientation = Vector3.new(0,Torso.Orientation.Y,0)
HumanoidRootPart.Orientation = Vector3.new(0,HumanoidRootPart.Orientation.Y,0)
end
end
There’s quite a lot of things to touch up on here.
First of all, to resolve your issue.
Changing the Position or Orientation of a part will break any joints it has. This means that when you change the orientation of your root part or torso, you’re breaking the joints of the character, resulting in the weird behavior you see.
To avoid this, you have to change the CFrame instead.
You can construct a CFrame you need like so:
You also don’t need to be constantly setting the rotation of both the torso and root part. Just doing the root part is enough.
Lastly, loops that need to run constantly, or each frame, should not be done using while-do, but rather through RunService.PreRender.
Putting all this together, you final script should look something like this:
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
RunService.PreRender:Connect(function()
local Character = Players.LocalPlayer.Character
if not Character then return end
if not Character:FindFirstChild("HumanoidRootPart") then return end
local RootPart = Character.HumanoidRootPart
RootPart.CFrame = CFrame.new(RootPart.Position) * CFrame.Angles(0, math.rad(RootPart.Orientation.Y), 0)
end)