[UNSOLVED] foolish individual fails to script footplanting

WARNING: EXTREME BRAIN ROT AHEAD

so i have very little scripting knowledge and really just blasted copacabana and clicked buttons until i figured something out. i felt so clever when i finished writing this but ultimately it does NOTHING

would appreciate some help making this script function :3

local script, exists within the model the player morphs into (but also does not function in starterplayerscripts :3)

local player = game:GetService("Players").LocalPlayer
local character = script.Parent
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local MovementIKs = {}
local MovementParts = {}

--raycast
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true

-- front right leg
game:GetService("RunService").Heartbeat:Connect(function()
	local FRrayOrigin = character:WaitForChild("Rshoulder").Position
	local FRrayDirection = Vector3.new(0, -character.Humanoid.HipHeight-5, 0)
	
	local FRraycastResult = workspace:Raycast(FRrayOrigin, FRrayDirection, raycastParams)
	
	local function CharacterAdded(character)
		local P1 = Instance.new("Part")
		MovementParts[player] = P1
		P1.Parent = workspace
		P1.Name = "P1"
		P1.Anchored = true
		P1.CanCollide = false
		P1.CanQuery = false
		P1.CanTouch = false
		P1.Transparency = 1
		P1.Position = FRraycastResult
		
		local IK1 = Instance.new("IKControl")
		MovementIKs[character] = IK1
		IK1.Parent = character.Humanoid
		IK1.Name = "IK1"
		IK1.Type = Enum.IKControlType.LookAt
		IK1.ChainRoot = character:WaitForChild("Torso1")
		IK1.EndEffector = character:WaitForChild("RFpaw")
		IK1.Target = P1

		local function onDied()
			IK1:Destroy()
			P1:Destroy()
		end
	end
end)

-- front left leg
game:GetService("RunService").Heartbeat:Connect(function()
	local FLrayOrigin = character:WaitForChild("Lshoulder").Position
	local FLrayDirection = Vector3.new(0, -character.Humanoid.HipHeight-5, 0)

	local FLraycastResult = workspace:Raycast(FLrayOrigin, FLrayDirection, raycastParams)

	local function CharacterAdded(character)
		local P2 = Instance.new("Part")
		MovementParts[player] = P2
		P2.Parent = workspace
		P2.Name = "P1"
		P2.Anchored = true
		P2.CanCollide = false
		P2.CanQuery = false
		P2.CanTouch = false
		P2.Transparency = 1
		P2.Position = FLraycastResult
		
		local IK2 = Instance.new("IKControl")
		MovementIKs[character] = IK2
		IK2.Parent = character.Humanoid
		IK2.Name = "IK2"
		IK2.Type = Enum.IKControlType.LookAt
		IK2.ChainRoot = character:WaitForChild("Torso1")
		IK2.EndEffector = character:WaitForChild("LFpaw")
		IK2.Target = P2

		local function onDied()
			IK2:Destroy()
			P2:Destroy()
		end
	end
end)

-- back right leg
game:GetService("RunService").Heartbeat:Connect(function()
	local BRrayOrigin = character:WaitForChild("Rthigh").Position
	local BRrayDirection = Vector3.new(0, -character.Humanoid.HipHeight-5, 0)

	local BRraycastResult = workspace:Raycast(BRrayOrigin, BRrayDirection, raycastParams)

	local function CharacterAdded(character)
		local P3 = Instance.new("Part")
		MovementParts[player] = P3
		P3.Parent = workspace
		P3.Name = "P1"
		P3.Anchored = true
		P3.CanCollide = false
		P3.CanQuery = false
		P3.CanTouch = false
		P3.Transparency = 1
		P3.Position = BRraycastResult
		
		local IK3 = Instance.new("IKControl")
		MovementIKs[character] = IK3
		IK3.Parent = character.Humanoid
		IK3.Name = "IK3"
		IK3.Type = Enum.IKControlType.LookAt
		IK3.ChainRoot = character:WaitForChild("Torso3")
		IK3.EndEffector = character:WaitForChild("RBpaw")
		IK3.Target = P3

		local function onDied()
			IK3:Destroy()
			P3:Destroy()
		end
	end
end)

-- back left leg
game:GetService("RunService").Heartbeat:Connect(function()
	local BLrayOrigin = character:WaitForChild("Lthigh").Position
	local BLrayDirection = Vector3.new(0, -character.Humanoid.HipHeight-5, 0)

	local BLraycastResult = workspace:Raycast(BLrayOrigin, BLrayDirection, raycastParams)

	local function CharacterAdded(character)
		local P4 = Instance.new("Part")
		MovementParts[player] = P4
		P4.Parent = workspace
		P4.Name = "P1"
		P4.Anchored = true
		P4.CanCollide = false
		P4.CanQuery = false
		P4.CanTouch = false
		P4.Transparency = 1
		P4.Position = BLraycastResult
		
		local IK4 = Instance.new("IKControl")
		MovementIKs[character] = IK4
		IK4.Parent = character.Humanoid
		IK4.Name = "IK2"
		IK4.Type = Enum.IKControlType.LookAt
		IK4.ChainRoot = character:WaitForChild("Torso3")
		IK4.EndEffector = character:WaitForChild("LBpaw")
		IK4.Target = BLraycastResult.Position

		local function onDied()
			IK4:Destroy()
			P4:Destroy()
		end
	end
end)


-- player dies or leaves game
local function CharacterRemoving(character)
	MovementIKs[character] = nil
	MovementParts[character] = nil
end
local function PlayerRemoving(character)
	MovementIKs[character] = nil
	MovementParts[character] = nil
end
3 Likes

Not my code, but this should help reduce the brain rot.

local player = game:GetService("Players").LocalPlayer
local character = script.Parent
local MovementIKs = {}
local MovementParts = {}

--raycast
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true

local function createIKControl(character, rayOrigin, rayDirection, chainRoot, endEffector)
	game:GetService("RunService").Heartbeat:Connect(function()
		local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
		local part = Instance.new("Part")
		MovementParts[player] = part
		part.Parent = workspace
		part.Name = "P1"
		part.Anchored = true
		part.CanCollide = false
		part.CanQuery = false
		part.CanTouch = false
		part.Transparency = 1
		part.Position = raycastResult.Position
		
		local ik = Instance.new("IKControl")
		MovementIKs[character] = ik
		ik.Parent = character.Humanoid
		ik.Name = "IK2"
		ik.Type = Enum.IKControlType.LookAt
		ik.ChainRoot = chainRoot
		ik.EndEffector = endEffector
		ik.Target = raycastResult.Position

		local function onDied()
			ik:Destroy()
			part:Destroy()
		end
	end)
end

createIKControl(character, character:WaitForChild("Rshoulder").Position, Vector3.new(0, -character.Humanoid.HipHeight-5, 0), character:WaitForChild("Torso1"), character:WaitForChild("RFpaw"))
createIKControl(character, character:WaitForChild("Lshoulder").Position, Vector3.new(0, -character.Humanoid.HipHeight-5, 0), character:WaitForChild("Torso1"), character:WaitForChild("LFpaw"))
createIKControl(character, character:WaitForChild("Rthigh").Position, Vector3.new(0, -character.Humanoid.HipHeight-5, 0), character:WaitForChild("Torso3"), character:WaitForChild("RBpaw"))
createIKControl(character, character:WaitForChild("Lthigh").Position, Vector3.new(0, -character.Humanoid.HipHeight-5, 0), character:WaitForChild("Torso3"), character:WaitForChild("LBpaw"))

-- player dies or leaves game
local function CharacterRemoving(character)
	MovementIKs[character] = nil
	MovementParts[character] = nil
end
local function PlayerRemoving(character)
	MovementIKs[character] = nil
	MovementParts[character] = nil
end

2 Likes

unfortunately it doesn’t seem to do anything besides spam this in my output :frowning_face:

did you perhaps try debugging using the infamous print() function before going to the devforum?

1 Like

its caused by this, i think you meant raycastResult.Instance

1 Like

Sorry, it’s my first time writing a script from scratch using only my own knowledge and no tutorials or anything, so it’s bound to be messy.
Changing the target to “Instance” rather than “Position” does seem to let the script function… though it seems I need to do some tweaking :sweat_smile:


(Forgive the lag, just turned my PC on.)

Edited script

local player = game:GetService("Players").LocalPlayer
local character = script.Parent
local MovementIKs = {}

local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {character}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
raycastParams.IgnoreWater = true

local function createIKControl(character, rayOrigin, rayDirection, chainRoot, endEffector)
	game:GetService("RunService").Heartbeat:Connect(function()
		local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
		local ik = Instance.new("IKControl")
		MovementIKs[character] = ik
		ik.Parent = character.Humanoid
		ik.Type = Enum.IKControlType.LookAt
		ik.ChainRoot = chainRoot
		ik.EndEffector = endEffector
		ik.Target = raycastResult.Instance

		local function onDied()
			ik:Destroy()
		end
	end)
end

createIKControl(character, character:WaitForChild("Rshoulder").Position, Vector3.new(0, -character.Humanoid.HipHeight-5, 0), character:WaitForChild("Torso1"), character:WaitForChild("RFpaw"))
createIKControl(character, character:WaitForChild("Lshoulder").Position, Vector3.new(0, -character.Humanoid.HipHeight-5, 0), character:WaitForChild("Torso1"), character:WaitForChild("LFpaw"))
createIKControl(character, character:WaitForChild("Rthigh").Position, Vector3.new(0, -character.Humanoid.HipHeight-5, 0), character:WaitForChild("Torso3"), character:WaitForChild("RBpaw"))
createIKControl(character, character:WaitForChild("Lthigh").Position, Vector3.new(0, -character.Humanoid.HipHeight-5, 0), character:WaitForChild("Torso3"), character:WaitForChild("LBpaw"))

local function CharacterRemoving(character)
	MovementIKs[character] = nil
end
local function PlayerRemoving(character)
	MovementIKs[character] = nil
end

annd I don’t know why it’s looking like this… because I have walk animations playing?? I don’t know :frowning:

ALSO IF YOU LET THE GAME RUN FOR MORE THAN LIKE 30 SECONDS IT STARTS WORKING AT 1FPS LMAO

I did, thanks for the feedback

2 Likes

If your game has 1 F.P.S and your machine isn’t your grandma’s then there’s a serious problem with performance…
Anyways

Shouldn’t it be Transform?

That gets the Instance but it’s not even offsetted, you should have a target part ( Not the End Effector ) that is cframed to RaycastResult.Position and set .Target to.
Also I notice serious unoptimized code, like having 4 heartbeats running, barely any variables usage, and making a function every frame.

1 Like

I believe I fixed the performance issue but I’m lost on the rest haha