Free R6 Footplant

No images, too lazy.
Would be better if you used a R6 IK module such as IKB.
FIXED AN ISSUE WHERE IT WOULD ONLY FOR ONE PLAYER THANKS TO THE REPORT GIVEN BY @Covolts

Hello person reading this, as you have read from the title ( Hopefully ) I’m here to enlighten your legs with this quick script I made.
Explanation:
This script places your legs on the ground using Raycast, that’s it.

The script itself is just very simple as it doesn’t even use Inverse Kinematics just RaycastResult.Distance and very wonky rotation.

I actually don’t recommend just taking and putting this in your game but actually play with it for a bit because it has many issues, I would only use this to learn how it works, how you can use Raycast to get the ground and that’s just it.

The script RunContext is supposed to be Server and preferably parented to ServerScriptService:

--[[
Hi.
Emper here.
Do you mind giving credits? Yes I know it's trash but I'm a human too :heartbroken:
Made in not more than 30 minutes.
No Rotation.
Uses Lerp.
Supposed to be a Script in ServerScriptService.
If you use this without editing it consider staying 1000 studs away from me or I will be forced to call the local authorithies.
]]
local Wait = task.wait
local Spawn = task.spawn

local function Instances(Parent, ClassName, Name)
	if typeof(Parent) == "Instance" and type(ClassName) == "string" and type(Name) == "string" then
		local Children = Parent:GetChildren()
		
		for Index = 1, # Children do
			local Instance = Children[Index]
			
			if Instance:IsA(ClassName) and Instance.Name == Name then
				return Instance
			end
		end
	end
end

local function WaitForChildOfClassAndName(...)
	while Wait() do
		local Instance = Instances(...)
		
		if Instance then
			return Instance
		end
	end
end

local function Parent(Instance)
	return typeof(Instance) == "Instance" and Instance.Parent
end

local function Lerp(JointInstance, CFrame, Speed)
	if Parent(JointInstance) and JointInstance:IsA("JointInstance") and typeof(CFrame) == "CFrame" and type(Speed) == "number" then
		JointInstance.C0 = JointInstance.C0:Lerp(CFrame, Speed)
	end
end

local Workspace = game:FindFirstChildOfClass("Workspace")

local CFramenew = CFrame.new
local CFrameAngles = CFrame.Angles

local Right = CFramenew(1, - 1, 0)
local Left = CFramenew(- 1, - 1, 0)

local RaycastParamsnew = RaycastParams.new
local Exclude = Enum.RaycastFilterType.Exclude

local PreSimulation = game:FindFirstChildOfClass("RunService").PreSimulation
local RaycastDirection = Vector3.new(0, - 2, 0)

game:FindFirstChildOfClass("Players").PlayerAdded:Connect(function(PlayerAdded)
	PlayerAdded.CharacterAdded:Connect(function(CharacterAdded)
		Spawn(function()
			local HumanoidRootPart = WaitForChildOfClassAndName(CharacterAdded, "BasePart", "HumanoidRootPart")
			
			local RightLeg = WaitForChildOfClassAndName(CharacterAdded, "BasePart", "Right Leg")
			local LeftLeg = WaitForChildOfClassAndName(CharacterAdded, "BasePart", "Left Leg")
			
			local Torso = WaitForChildOfClassAndName(CharacterAdded, "BasePart", "Torso")
			
			local RightHip = WaitForChildOfClassAndName(Torso, "JointInstance", "Right Hip")
			local RightHipC0 = RightHip.C0
			
			local LeftHip = WaitForChildOfClassAndName(Torso, "JointInstance", "Left Hip")
			local LeftHipC0 = LeftHip.C0
			
			local RaycastParameters = RaycastParamsnew()
			RaycastParameters.FilterDescendantsInstances = { CharacterAdded }
			RaycastParameters.FilterType = Exclude
			
			PreSimulation:Connect(function(DeltaTime)
				if Parent(CharacterAdded) and Parent(HumanoidRootPart) then
					local DeltaTime = DeltaTime * 10
					
					local HumanoidRootPartCFrame = HumanoidRootPart.CFrame
					
					if RightLeg then
						local RaycastResult = Workspace:Raycast(( HumanoidRootPartCFrame * Right ).Position, RaycastDirection, RaycastParameters)
						
						if RaycastResult then
							local Distance = RaycastResult.Distance - 2
							
							Lerp(RightHip, RightHipC0 * CFramenew(- Distance, 0, 0) * CFrameAngles(0, 0, Distance), DeltaTime)
						else
							Lerp(RightHip, RightHipC0, DeltaTime)
						end
					end
					
					if LeftLeg then
						local RaycastResult = Workspace:Raycast(( HumanoidRootPartCFrame * Left ).Position, RaycastDirection, RaycastParameters)
						
						if RaycastResult then
							local Distance = RaycastResult.Distance - 2
							
							Lerp(LeftHip, LeftHipC0 * CFramenew(Distance, 0, 0) * CFrameAngles(0, 0, - Distance), DeltaTime)
						else
							Lerp(LeftHip, LeftHipC0, DeltaTime)
						end
					end
				end
			end)
		end)
	end)
end)

RBXL where you test it.
footplant.rbxl (54.7 KB)
Have fun using this.

24 Likes

If anyone likes this even in the slightest you’re literally delusional.

8 Likes

my fault
image

5 Likes

Stay math.huge studs away from me before we’re gonna have a problem.
I appreciate it though :heart:

4 Likes

why would you call people who like it “delusional”??? You know people will be upset because of that


I need some images, if ur too lazy, I will set it up on ur behalf

1 Like

Sadly too lazy to add images… You can do it though

1 Like

For anyone wondering how this looks in-game, since Empereans didn’t want to share any images or videos, I went ahead and collected some visuals to show you how it looks

Stairs:


Ramp/Wedge:


Video Demonstration:

The footplanting is okay, but it does look a little weird when walking sideways on stairs or ramps. Besides that, it’s fine. Oh, and by the way, this also works with custom animations

4 Likes

Your R6 footplanting system is pretty good, it only works on one player though, if there are multiple players present it’ll only work for a single one. This resets to a random player once the player for which it does function dies.

Weird. I’ll look into that and try to fix it. Thanks for the report.

1 Like

Thank you for reporting that I just fixed it!

1 Like

my bad bro -------------------------------------