Make a part always above whatever other part it is touching it

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I would like to make it so that a (non-colliding) part attached to the foot is always hovering on the top of whatever part the foot is touching. I am attempting to create an IK footing system and need to know where to put the foot.

  1. What is the issue? Include screenshots / videos if possible!

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I have tried using a prismatic constraint with cancollide on connected to the foot and the blue ball and have tried using part.Touched(function(hit) to make the blue ball go to the top of whatever it is touching, yet I haven’t found success.

local RS = game:GetService("RunService")

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()

local inplantposL = Instance.new("Part")
inplantposL.Name = "inplantposL"
inplantposL.Parent = char.LeftFoot
inplantposL.Shape = Enum.PartType.Ball
inplantposL.Size = Vector3.new(2,2,2)
inplantposL.Color = Color3.new(0, 0, 1)
inplantposL.CanCollide = false
inplantposL.Transparency = 0.5

RS.RenderStepped:Connect(function()
	inplantposL.Position = char.LeftFoot.Position + Vector3.new(0, char.LeftFoot.Size.Y / -2, 0)
end)

blueorb
How can I get that blue orb to be on top of a part, lets say the spawn point for that example.

I AM aware that it probably has something to do with changing the Y value of the position in the RenderStepped function, I am just not sure how to get the position the blue ball needs to be at.

Just for clarification, I am looking for a general solution, notfor an entire script or anything.

You probably would need some raycasting here in order to accomplish it.
This definitely would work, but im not very sure. Tell me if there’s any errors occur within my script!

local rcastprms = RaycastParams.new()
rcastprms.FilterDescendantsInstances = {partsThatIDoNotWantToTouch}
rcastprms.FilterType = Enum.RaycastFilterType.Exclude
rcastprms.RespectCanCollide = true -- optional ofc, i don't really know what it do but it definitely could help sometimes

RS.RenderStepped:Connect(function()
    local raycast = workspace:Raycast(char.LeftUpperLeg.Position,char.LeftFoot.Position - char.LeftUpperLeg.Position,rcastParams)
    if raycast then
	   inplantposL.Position = raycast.Position
    end
end)
1 Like

Sorry for the late reply,

This worked perfectly! Thank you for going the extra mile with the code and everything.
-By the way, for anyone viewing this: I set the FilterDescendantsInstances to

local charparts = char:GetChildren()

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.