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.