Weirdest bug i have every seen

i am trying to make a falldamage script in a localscript and i thought it would be cool if i rotate the player upwards to look more like they are falling down but i get this super weird bug can anyone help fix it

this is my code

wait(3);
local l__Parent__1 = script.Parent;
local l__Humanoid__2 = l__Parent__1:WaitForChild("Humanoid");
while wait(0.5) do
	local v3 = RaycastParams.new();
	local v4 = {};
	for v5, v6 in ipairs(script.Parent:GetDescendants()) do
		if v6:IsA("BasePart") then
			table.insert(v4, v6);
		end;
	end;
	v3.FilterDescendantsInstances = v4;
	v3.FilterType = Enum.RaycastFilterType.Blacklist;
	if not workspace:Raycast(script.Parent.HumanoidRootPart.Position, Vector3.new(0, -30 * l__Humanoid__2.BodyHeightScale.Value, 0), v3) and l__Humanoid__2:GetState() ~= Enum.HumanoidStateType.Physics and l__Humanoid__2:GetState() ~= Enum.HumanoidStateType.Climbing then
		local v7 = l__Humanoid__2:GetState() ~= Enum.HumanoidStateType.Physics;
		local v8 =l__Humanoid__2:GetState() ~= Enum.HumanoidStateType.PlatformStanding;
		l__Humanoid__2:ChangeState(v7 and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp);
		l__Parent__1.Animate.Disabled = v7;
		script.Parent:WaitForChild("HumanoidRootPart").Orientation = Vector3.new(-90, Y, Z)
		local hptake = 0
		while not workspace:Raycast(script.Parent.HumanoidRootPart.Position, Vector3.new(0, -30 * l__Humanoid__2.BodyHeightScale.Value, 0), v3) and l__Humanoid__2:GetState() ~= Enum.HumanoidStateType.Physics and l__Humanoid__2:GetState() ~= Enum.HumanoidStateType.Climbing do
			hptake = hptake + 25
			wait(1)
		end;
		wait(1)
		l__Humanoid__2:ChangeState(Enum.HumanoidStateType.GettingUp);
		l__Parent__1.Animate.Enabled = v8;
		script.Parent:WaitForChild("HumanoidRootPart").Orientation = Vector3.new(0, 0, 0)
		script.Parent:WaitForChild("Humanoid").Health = script.Parent:WaitForChild("Humanoid").Health - hptake
		hptake = 0
	end;
end;

what bug do you mean, please specify more :happy2:

Its not a “bug” its the Humanoid trying to preserve its normal rotation due to the Humanoid Controller.

A possible approach if you want to rotate the characters in that way, is building your own Controller.
I found that issue when I tried to make a system where you walk over a sphere, like a planet with gravity, so the best way I found is creating a custom controller for the character, and disabling the default one.

You could give it a check to this module to understand how to achieve it and build your own one, or try to use it

You want them to stop flipping back upwards?

Humanoid:ChangeState(Enum.HumanoidStateType.Physics)

Then when they hit the ground

Humanoid:ChangeState(Enum.HumanoidStateType.Landed)
1 Like

don’t take this the wrong way, but this looks quite similar to decompiled code. is this a free model that you’re trying to modify?

Also perhaps I should mention that if you replace the default falling/landed sequence with a humanoidstate physics + custom landing detection(touched event or raycast), the player would spin as they fell to the ground, as Physics would give the character the physics of any other part. You’d have to combine the physics state with an align orientation with a lowish force to bias the orientation to the way it is in your photo.

I encountered this bug before when I tried anchoring a HumanoidRootPart and setting its CFrame. It resulted in weird displacements that affected my game’s PVP quite a bit. I solved this one by using :PivotTo() on the character model rather than manually editing the HumanoidRootPart’s CFrame and the weird displacement issue disappeared.

I think this is because of the semicolons in your code. Consider removing them.

Semicolons are a preference, it does not alter how the code runs.

Please stay on topic and help this man with his altered decompiled code.