How could I make your arms and head follow your mouse up and down?

I think this is solved because nobody is posting.

I still dont get this
i need this for my game

Yo i am confused too because i am trying to make the same thing but i don’t understand what i nead to do in your script to make it work! here what i am in your script!:


also here is the error

nvm i found out how to do it lol

Hi sorry to bump this topic but I’m using this code for the arms:

        local rightX, rightY, rightZ = char.Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()
		char.Torso["Right Shoulder"].C0 = (char.Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouse.Hit.p - mouse.Origin.p).unit.y))

		local leftX, leftY, leftZ = char.Torso["Left Shoulder"].C0:ToEulerAnglesYXZ()
		char.Torso["Left Shoulder"].C0 = (char.Torso["Left Shoulder"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-mouse.Hit.p - -mouse.Origin.p).unit.y))

But when I go into first person the arms start moving closer/away from the camera:

Does anyone know how I can fix this?

Edit:
I also used this but it acts the same way:

        char.Torso["Right Shoulder"].C0 = CFrame.new(1,0.5,0) * CFrame.Angles(-math.asin((mouse.Origin.p - mouse.Hit.p).unit.y),1.55,0)
		char.Torso["Left Shoulder"].C0 = CFrame.new(-1,0.5,0) * CFrame.Angles(-math.asin((mouse.Origin.p - mouse.Hit.p).unit.y),-1.55,0)
1 Like

Because your arms are rotating relative to themselves, not the camera. And since the camera rotates relative to itself, it doesn’t line up. You either have to use a view model, make the arms move relative to the camera, or move the camera relative to the arms.

1 Like

I am having this problem too

but I dont how to fix and yes I am using Motor6D animations

I’m pretty sure he’s looking for an R6 version of this, this script is meant for R15 rigs.

Hello, sorry for the bump, but how did you do it? I don’t know how to use “self” and what i found in devforum doesn’t explain why studio says "unknown global ’ self ’ " i really like this arm pointing to camera (or mouse) effect

You can do

local Char = game.Players.LocalPlayer.Character;

and replace every

self.char

with

Char
1 Like

I made some changes so the arms point their bottom face instead of front but it worked, thanks!!

i just changed self.Right arm to this :

local run = game:GetService("RunService")

local equipped = false

local player = game.Players.LocalPlayer

local char = game.Players.LocalPlayer.Character

repeat wait() until player.Character


print(player.Name)

local mouse = game.Players.LocalPlayer:GetMouse()

local Torso = game.Players.LocalPlayer.Character.Torso

local RightArm = game.Players.LocalPlayer.Character['Right Arm']


script.Parent.Equipped:Connect(function()



run.RenderStepped:Connect(function()

equipped = true

local rightX, rightY, rightZ = Torso["Right Shoulder"].C0:ToEulerAnglesYXZ()

Torso["Right Shoulder"].C0 = (Torso["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouse.Hit.p - mouse.Origin.p).unit.y))

local leftX, leftY, leftZ = Torso["Left Shoulder"].C0:ToEulerAnglesYXZ()

Torso["Left Shoulder"].C0 = (Torso["Left Shoulder"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-mouse.Hit.p - -mouse.Origin.p).unit.y))

end)

end)

script.Parent.Equipped:Connect(function()

game.ReplicatedStorage.ConnectM6D:FireServer(WeaponTool.BodyAttach)

RightArm.ToolGrip.Part0 = RightArm

RightArm.ToolGrip.Part1 = WeaponTool.BodyAttach

end)

WeaponTool.Unequipped:Connect(function()


game.ReplicatedStorage.DisconnectM6D:FireServer()

end)
2 Likes

Good idea, I isolated the mouse following parts of the scripts you’re referring to, specifically the pistol’s scripts from the following game.

https://www.roblox.com/games/203885589/Combat

--LOCAL

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("RemoteEvent")
local run = game:GetService("RunService")
local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character	
local humanoid = character:WaitForChild("Humanoid")
local root = character:WaitForChild("HumanoidRootPart")
local head = character:WaitForChild("Head")
local torso, rightArm, neck, rightShoulder
if humanoid.RigType == Enum.HumanoidRigType.R6 then
	torso = character:WaitForChild("Torso")
	rightArm = character:WaitForChild("Right Arm")
	neck = torso:WaitForChild("Neck")
	rightShoulder = rightArm:WaitForChild("Right Shoulder")
elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
	torso = character:WaitForChild("UpperTorso")
	rightArm = character:WaitForChild("RightUpperArm")
	neck = head:WaitForChild("Neck")
	rightShoulder = rightArm:WaitForChild("RightShoulder")
end

local function onRenderStep()
	local state = humanoid:GetState()
	if not state then return end
	if state == Enum.HumanoidStateType.Swimming then return end
	local mousePosition = mouse.Hit.Position
	local toMouse = (mousePosition - head.Position).Unit
	local angle = math.acos(toMouse:Dot(Vector3.new(0, 1, 0)))
	local neckAngle = angle

	if math.deg(neckAngle) > 110 then
		neckAngle = math.rad(110)
	end

	if humanoid.RigType == Enum.HumanoidRigType.R6 then
		neck.C0 = CFrame.new(0, 1, 0) * CFrame.Angles(math.pi - neckAngle, math.pi, 0)
	elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
		neck.C0 = CFrame.new(0, 0.84, 0) * CFrame.Angles(math.pi/2 - neckAngle, 0, 0)
	end
	
	local fromArmPos = torso.Position + torso.CFrame:vectorToWorldSpace(Vector3.new(torso.Size.X/2 + rightArm.Size.X/2, torso.Size.Y/2 - rightArm.Size.Z/2, 0))
	local toMouseArm = ((mousePosition - fromArmPos) * Vector3.new(1, 0, 1)).Unit
	local look = (torso.CFrame.lookVector * Vector3.new(1, 0, 1)).Unit
	local lateralAngle = math.acos(toMouseArm:Dot(look))

	if tostring(lateralAngle) == "-1.#IND" then
		lateralAngle = 0
	end
	
	if state == Enum.HumanoidStateType.Seated then
		local cross = root.CFrame.lookVector:Cross(toMouseArm)
		if lateralAngle > math.pi/2 then
			lateralAngle = math.pi/2
		end
		if cross.Y < 0 then
			lateralAngle = -lateralAngle
		end
	end	

	if humanoid.RigType == Enum.HumanoidRigType.R6 then
		rightShoulder.C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(math.pi/2 - angle, math.pi/2 + lateralAngle, 0)
	elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
		rightShoulder.C0 = CFrame.new(1.25, 0.5, 0) * CFrame.Angles(math.pi/2 - angle, lateralAngle, 0)
	end

	if state ~= Enum.HumanoidStateType.Seated then
		root.CFrame = CFrame.lookAt(root.Position, root.Position + (Vector3.new(mousePosition.X, root.Position.Y, mousePosition.Z) - root.Position).Unit)
	end
	
	remote:FireServer(neck.C0, rightShoulder.C0)
end

run.RenderStepped:Connect(onRenderStep)
--SERVER

local replicated = game:GetService("ReplicatedStorage")
local remote = replicated.RemoteEvent

local function onRemoteFired(player, neckC0, rightShoulderC0)
	local character = player.Character
	if not character then return end
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid then return end
	if humanoid.Health <= 0 then return end
	if humanoid.RigType == Enum.HumanoidRigType.R6 then
		local torso = character.Torso
		local neck = torso.Neck
		local rightShoulder = torso["Right Shoulder"]
		neck.C0 = neckC0
		rightShoulder.CO = rightShoulderC0
	elseif humanoid.RigType == Enum.HumanoidRigType.R15 then
		local head = character.Head
		local neck = head.Neck
		local rightArm = character.RightUpperArm
		local rightShoulder = rightArm.RightShoulder
		neck.C0 = neckC0
		rightShoulder.C0 = rightShoulder.C0
	end
end

remote.OnServerEvent:Connect(onRemoteFired)

Here’s the place file for anyone that may need it.
Mouse.rbxl (27.9 KB)

1 Like

Since you did not say what in the vid you wanted to make, I will assume you meant the effect of the sword, it is just a simple trail with two attachments and a decal…

Then as he is running it makes the trail.

The arms movement, how you can move so freely

It just looks like a custom animation…

1 Like

It seems when I run the mouse.rbxl , the players right shoulder has a gap from the body…

image

It isn’t moving arms would just fall, and the user can control them there.

I managed to cloned left shoulder and right shoulder welded and parented to the head and make the neck move up and down by the camera with RunService.RenderStepped also use RunService.Stepped to update the animation from the real joint to fake joint
Put this script in StarterCharacterScripts

--R6 Only
local RunService = game:GetService("RunService")

local camera = workspace.CurrentCamera
local character = script.Parent

local torso = character:WaitForChild("Torso")
local head = character:WaitForChild("Head")

local rightShoulder = torso:WaitForChild("Right Shoulder")
local leftShoulder = torso:WaitForChild("Left Shoulder")
local neck = torso:WaitForChild("Neck")

local rightShoulderCopy = Instance.new("Motor6D")
rightShoulderCopy.C0 = CFrame.new(1.5, -1, 0) * rightShoulder.C0.Rotation
rightShoulderCopy.C1 = CFrame.new(0, .5, 0) * rightShoulder.C1.Rotation
rightShoulderCopy.Part1 = rightShoulder.Part1
rightShoulderCopy.Name = "RightShoulderCopy"
rightShoulderCopy.Archivable = false
rightShoulderCopy.Part0 = head
rightShoulderCopy.Parent = head

local leftShoulderCopy = Instance.new("Motor6D")
leftShoulderCopy.C0 = CFrame.new(-1.5, -1, 0) * leftShoulder.C0.Rotation
leftShoulderCopy.C1 = CFrame.new(0, .5, 0) * leftShoulder.C1.Rotation
leftShoulderCopy.Part1 = leftShoulder.Part1
leftShoulderCopy.Name = "LeftShoulderCopy"
leftShoulderCopy.Archivable = false
leftShoulderCopy.Part0 = head
leftShoulderCopy.Parent = head

rightShoulder.Enabled = false
leftShoulder.Enabled = false

RunService.RenderStepped:Connect(function()
	neck.C0 = CFrame.new(0, 1.5, 0) * CFrame.Angles(math.asin((camera.Focus.Position - camera.CFrame.Position).Unit.Y), 0, 0)
	neck.C1 = CFrame.new()
end)

RunService.Stepped:Connect(function()
	rightShoulderCopy.Transform = rightShoulder.Transform
	leftShoulderCopy.Transform = leftShoulder.Transform
end)

workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function()
	local _camera = workspace.CurrentCamera
	if _camera then
		camera = _camera
	end
end)

Hope this fixed for you

1 Like