Make hand follow your mouse target

I have achieved this, but I want it to be server sided so all of the players can see it.
Since it’s rendersteppdet, idk how I would achieve something like this.

Here’s the script:

local RunService = game:GetService("RunService")

local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()

local Camera = workspace.CurrentCamera
local Mouse = Player:GetMouse()

local Character = Player.Character or Player.CharacterAdded:Wait()
local RArm = Character:WaitForChild("RightUpperArm")
local RShoulder = RArm:WaitForChild("RightShoulder")

local Torso = Character:WaitForChild("UpperTorso")

local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")

local RShoulderOriginC0 = RShoulder.C0

RShoulder.MaxVelocity = 1/3

RunService.RenderStepped:Connect(function() 
		local CameraCFrame = Camera.CoordinateFrame
	
	if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
		local TorsoLookVector = Torso.CFrame.lookVector
		local ArmPosition = RArm.CFrame.p
		
		if RShoulder then
			if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
				local Point = Mouse.Hit.Position
				
				local Distance = (RArm.CFrame.p - Point).magnitude
				local Difference = RArm.CFrame.Y - Point.Y
				
				RShoulder.C0 = RShoulder.C0:lerp(RShoulderOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 1), (((ArmPosition - Point).Unit):Cross(TorsoLookVector)).Y * 1, 0) * CFrame.Angles(math.rad(90), 0, 0), 0.5 / 2)
				--Waist.C0 = Waist.C0:lerp(WaistOriginC0 * CFrame.Angles(-(math.atan(Difference / Distance) * 0.5), (((HeadPosition - Point).Unit):Cross(TorsoLookVector)).Y * 0.5, 0), 0.5 / 2)
			end
		end
	end	
end)

Here’s what it looks like in-game:
85b8a7576d6da71239b03a4890ca7ecf

1 Like

Check this video out

4 Likes