How would I make server side inverse kinematics

Ive looked through the internet for server-side inverse kinematics I could look at but most inverse kinematics scripts are only local and don’t appear for other people or they just don’t work in multiplayer

I have virtually no experience in inverse kinematics so any help is much appreciated.

1 Like

It’s very easy to make it server sided, its mostly the same process as how you’d do it on the client side, however wherever you use LocalScripts you’ll need to use server Scripts instead. Recently I made my own IKController for the look direction that’s completely server sided.

I did this by creating a server Script in ServerScriptService that creates the IKControl Instance when a player & character have been added, I then created a target Part which will be the target for my IK, as I needed the lookVector from the workspace.CurrentCamera I needed to create a LocalScript in the PlayerScripts folder that sends the lookVector so that the target part can be repositioned to make the IK look in the direction the camera is.

Note: If you’re using my example, you need a remote event in replicatedStorage for the server script and local scripts to be able to communicate the lookVector across.

Here is the simple version of my code:

ServerScriptService Script:

-- Look Inverse Kinematics Manager v1 by DeicideFelidae AKA DumbCat

-- On Player Added:
game.Players.PlayerAdded:Connect(function(player)
	
	-- When the character is fully loaded:
	player.CharacterAppearanceLoaded:Connect(function(character)
		task.wait()
		
		-- IKController:
		local lookController = Instance.new("IKControl")
		lookController.Name = "lookController"
		lookController.Parent = character:WaitForChild("Humanoid")
		lookController.Enabled = true
		lookController.Type = Enum.IKControlType.LookAt
		lookController.EndEffector = character:WaitForChild("Head")
		lookController.ChainRoot = character:WaitForChild("UpperTorso")
		lookController.SmoothTime = 0.1

		-- Target Part:
		local target = Instance.new("Part")
		target.Name = player.Name .. "sLookTarget"
		target.Anchored = true
		target.Parent = workspace.CharacterStuff
		target.CanCollide = false
		target.CanQuery = false
		target.CanTouch = false
		target.Transparency = 1
		target.Size = Vector3.one
		target.CFrame = CFrame.new(character.Head.Position + character.Head.CFrame.lookVector * 10)
		
		lookController.Target = target
		
		local lookDirection = CFrame.new(character.Head.Position + character.Head.CFrame.lookVector * 10).Position
		
		game.ReplicatedStorage.InverseKinematics.lookDirection.OnServerEvent:Connect(function(eventPlayer, lookVector)
			if eventPlayer == player then
				lookDirection = lookVector
			end 			
		end)
		
		-- Update Loop:
		while character do
			task.wait(0.05)
			-- Request Look Direction:
			game.ReplicatedStorage.InverseKinematics.getLookDirection:FireClient(player)
			
			target.CFrame = CFrame.new(character.Head.Position + lookDirection * 10)
			
		end
	end)
end)

PlayerScript LocalScript:

-- Look Direction Grabber v1 by DeicideFelidae AKA DumbCat

-- Get Update Event:
game.ReplicatedStorage.InverseKinematics.getLookDirection.OnClientEvent:Connect(function()
	game.ReplicatedStorage.InverseKinematics.lookDirection:FireServer(workspace.CurrentCamera.CFrame.LookVector)
end)

I hope this helps.