How would I make the players arm move accordingly to the y position of the mouse?

I’m trying to make a physics based item where it’ll shoot the tip of a projectile in the direction that the players mouse is facing. (While their mouse is locked in middle.) the only downside to this is, since you can’t really make the item look upwards or downwards. if a player tries to look that way the position of the tip will be inaccurate.

Any way to make it so you can move your arm up to match the camera to basically fit this need?

You could just perform a CFrame.lookAt() assignment on the held item, I did write this however.

do
	local Game = game
	local RunService = Game:GetService("RunService")
	local Players = Game:GetService("Players")
	local Player = Players.LocalPlayer
	local Mouse = Player:GetMouse()
	local Character = Player.Character or Player.CharacterAdded:Wait()
	local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")
	local RigType = Humanoid.RigType.Name
	local Limb = if RigType == "R6" then Character:FindFirstChild("Torso") or Character:WaitForChild("Torso") elseif RigType == "R15" then Character:FindFirstChild("RightUpperArm") or Character:WaitForChild("RightUpperArm") else nil
	if not Limb then return end
	local Joint = if RigType == "R6" then Limb:FindFirstChild("Right Shoulder") or Limb:WaitForChild("Right Shoulder") elseif RigType == "R15" then Limb:FindFirstChild("RightShoulder") or Limb:WaitForChild("RightShoulder") else nil
	if not Joint then return end

	local function OnRenderStep()
		Joint.C0 = CFrame.lookAt(Joint.C0.Position, Vector3.new(Joint.C0.Position.X, Mouse.Hit.Position.Y, math.min(Mouse.Hit.Position.Z, Joint.C0.Position.Z))) * CFrame.Angles(-math.pi / 2, 0, math.pi)
	end
	
	RunService.RenderStepped:Connect(OnRenderStep)
end
4 Likes