How would I make a players arm move depending on the y axis of the mouse? (R6)

If you run this snippet of code in a local script in StarterCharacterScripts it should get you what you need, sorry that you had to wait a year for this.

plr = game.Players.LocalPlayer;
repeat
	wait()
until plr.Character
char = plr.Character
m = plr:GetMouse()
local IsEquipped = false


local origRightS = char:WaitForChild("Torso"):WaitForChild("Right Shoulder").C0
local origLeftS = char:WaitForChild("Torso"):WaitForChild("Left Shoulder").C0
local origNeck = char:WaitForChild("Torso"):WaitForChild("Neck").C0
local camera = game.Workspace.CurrentCamera

local UIS = game:GetService("UserInputService")

local c = game.Workspace.CurrentCamera

game:GetService("RunService").RenderStepped:Connect(function(delta)
	
	
	

	if IsEquipped == true then
		
			if char.Torso:FindFirstChild("Right Shoulder") then
				char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), 1.55, 0, 0) , 0.1)
			end
			if char.Torso:FindFirstChild("Left Shoulder") then
				char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), -1.55, 0, 0) , 0.1)
			end
			if char.Torso:FindFirstChild("Neck") then
				char.Torso["Neck"].C0 = char.Torso["Neck"].C0:Lerp(CFrame.new(0, 1, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55, 3.15, 0), 0.2)
			end
		
		else
		
			if char.Torso:FindFirstChild("Right Shoulder") then
				char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:lerp(origRightS, 0.1)
			end
		

			if char.Torso:FindFirstChild("Left Shoulder") then
				char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:lerp(origLeftS, 0.1)
			end

		

			if char.Torso:FindFirstChild("Neck") then
				char.Torso["Neck"].C0 = char.Torso["Neck"].C0:lerp(origNeck, 0.1)
			end

		
	end
	
	
	
end)


char.ChildAdded:Connect(function(instance)
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Tool") then
			if v:FindFirstChild("HoldArmsStill") then
				
			else
				IsEquipped = true
				
			end
		end
	end
end)

char.ChildRemoved:Connect(function(instance)
	if instance:IsA("Tool") then
		IsEquipped = false
	end
end)



Please ignore any weird variables, this was for my other game and I had to delete a few things to make it work for you

7 Likes

Oh my lord, thank you so MUCH! I was beginning to lose hope in my game just because this one thing.

3 Likes

its alright, im happy to help anytime

2 Likes

I forgor :skull:
Can you edit the script where the head does not move?
Sorry for asking!

2 Likes

yeah sure,

plr = game.Players.LocalPlayer;
repeat
	wait()
until plr.Character
char = plr.Character
m = plr:GetMouse()
local IsEquipped = false


local origRightS = char:WaitForChild("Torso"):WaitForChild("Right Shoulder").C0
local origLeftS = char:WaitForChild("Torso"):WaitForChild("Left Shoulder").C0
local origNeck = char:WaitForChild("Torso"):WaitForChild("Neck").C0
local camera = game.Workspace.CurrentCamera

local UIS = game:GetService("UserInputService")

local c = game.Workspace.CurrentCamera

game:GetService("RunService").RenderStepped:Connect(function(delta)




	if IsEquipped == true then

		if char.Torso:FindFirstChild("Right Shoulder") then
			char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), 1.55, 0, 0) , 0.1)
		end
		if char.Torso:FindFirstChild("Left Shoulder") then
			char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), -1.55, 0, 0) , 0.1)
		end

	else

		if char.Torso:FindFirstChild("Right Shoulder") then
			char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:lerp(origRightS, 0.1)
		end


		if char.Torso:FindFirstChild("Left Shoulder") then
			char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:lerp(origLeftS, 0.1)
		end


	end



end)


char.ChildAdded:Connect(function(instance)
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Tool") then
			if v:FindFirstChild("HoldArmsStill") then

			else
				IsEquipped = true

			end
		end
	end
end)

char.ChildRemoved:Connect(function(instance)
	if instance:IsA("Tool") then
		IsEquipped = false
	end
end)

tada

6 Likes

Is possible to make it show for all clients? (Fire one RemoteEvent from local into server side)

5 Likes

@mrkomps @johncena12345678953

Sorry for reply.

I used mrkomps script and I changed for all clients and looks something like this

sorry for the lag

*Local script*

local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local char = Player.Character
local origRightS = char:WaitForChild("Torso"):WaitForChild("Right Shoulder").C0
local origLeftS = char:WaitForChild("Torso"):WaitForChild("Left Shoulder").C0
local origNeck = char:WaitForChild("Torso"):WaitForChild("Neck").C0

local m = Player:GetMouse()

local UIS = game:GetService("UserInputService")

local IsEquipped = false

game:GetService("RunService").RenderStepped:Connect(function()
	if IsEquipped == true then

		if char.Torso:FindFirstChild("Right Shoulder") then
			char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), 1.55, 0, 0) , 0.1)
		end
		if char.Torso:FindFirstChild("Left Shoulder") then
			char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), -1.55, 0, 0) , 0.1)
		end
		if char.Torso:FindFirstChild("Neck") then
			char.Torso["Neck"].C0 = char.Torso["Neck"].C0:Lerp(CFrame.new(0, 1, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55, 3.15, 0), 0.2)
		end

	else

		if char.Torso:FindFirstChild("Right Shoulder") then
			char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:lerp(origRightS, 0.1)
		end

		if char.Torso:FindFirstChild("Left Shoulder") then
			char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:lerp(origLeftS, 0.1)
		end

		if char.Torso:FindFirstChild("Neck") then
			char.Torso["Neck"].C0 = char.Torso["Neck"].C0:lerp(origNeck, 0.1)

		end
	end
end)

char.ChildAdded:Connect(function()
	for i,v in pairs(char:GetChildren()) do
		if v:IsA("Tool") then
			if v:FindFirstChild("HoldArmsStill") then

			else
				IsEquipped = true

			end
		end
	end
end)

game.ReplicatedStorage.Look.OnClientEvent:Connect(function(PlrAgain, neckCFrame, RsCFrame, LsCFrame)
	local Neck = PlrAgain.Character.Torso:FindFirstChild("Neck", true)
	local Rs = PlrAgain.Character.Torso:FindFirstChild("Right Shoulder", true)
	local Ls = PlrAgain.Character.Torso:FindFirstChild("Left Shoulder", true)
	
	if Neck then
		Neck.C0 = neckCFrame
	end
	
	if Rs then
		Rs.C0 = RsCFrame
	end
	
	if Ls then
		Ls.C0 = LsCFrame
	end
end)

while wait(2) do -- you can change here if you want
	game.ReplicatedStorage.Look:FireServer(char.Torso["Neck"].C0, char.Torso["Right Shoulder"].C0, char.Torso["Left Shoulder"].C0)
end


*ServerSide*

game.ReplicatedStorage.Look.OnServerEvent:Connect(function(player, neckCFrame, RsCFrame, LsCFrame)
	for key, value in pairs(game.Players:GetChildren()) do
		if value ~= player then
			game.ReplicatedStorage.Look:FireClient(value, player, neckCFrame, RsCFrame, LsCFrame)
		end
	end
end)

Note: The RemoteEvent is “Look” and is inside the RS(ReplicatedStorage)

17 Likes

you can use this script to make it look like a viewmodel

1 Like

Yeah, I just use this module, with some edits I made.

2 Likes

How do you weld the tool to the arms so that they can rotate too?

3 Likes

Can you help me do that please @ToxicalGamer2006
I do that follow you and it’s not working, here is video
sorry my for the title red :sweat_smile:

and here is picture place script and remote event:

2 Likes

You haven’t implemented .OnServerEvent yet and havent call :FireServer() every 0.1 second

2 Likes

can you show me step by step and where to put the script and full how-to video? @thebrickplanetboy

2 Likes

create a script not localscript and place it in ServerScriptService then paste this code here:

game.ReplicatedStorage.Look.OnServerEvent:Connect(function(player, neckCFrame, RsCFrame, LsCFrame)
	for key, value in pairs(game.Players:GetChildren()) do
		if value ~= player then
			game.ReplicatedStorage.Look:FireClient(value, player, neckCFrame, RsCFrame, LsCFrame)
		end
	end
end)

the video is from above

4 Likes

@thebrickplanetboy thanks it working but can you make it disable 2 arms not move follow head when unuse tools please, only head look and when use, 2 arms it will can follow tools

2 Likes

ok


local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer

local char = Player.Character
local origRightS = char:WaitForChild("Torso"):WaitForChild("Right Shoulder").C0
local origLeftS = char:WaitForChild("Torso"):WaitForChild("Left Shoulder").C0
local origNeck = char:WaitForChild("Torso"):WaitForChild("Neck").C0

local m = Player:GetMouse()

local UIS = game:GetService("UserInputService")

local IsEquipped = false

game:GetService("RunService").RenderStepped:Connect(function()
	if IsEquipped == true then
		if char.Torso:FindFirstChild("Right Shoulder") then
			char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:Lerp(CFrame.new(1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), 1.55, 0, 0) , 0.1)
		end
		if char.Torso:FindFirstChild("Left Shoulder") then
			char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:Lerp(CFrame.new(-1, .65, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y), -1.55, 0, 0) , 0.1)
		end
		if char.Torso:FindFirstChild("Neck") then
			char.Torso["Neck"].C0 = char.Torso["Neck"].C0:Lerp(CFrame.new(0, 1, 0) * CFrame.Angles(-math.asin((m.Origin.p - m.Hit.p).unit.y) + 1.55, 3.15, 0), 0.2)
		end
	else
		if char.Torso:FindFirstChild("Right Shoulder") then
			char.Torso["Right Shoulder"].C0 = char.Torso["Right Shoulder"].C0:lerp(origRightS, 0.1)
		end

		if char.Torso:FindFirstChild("Left Shoulder") then
			char.Torso["Left Shoulder"].C0 = char.Torso["Left Shoulder"].C0:lerp(origLeftS, 0.1)
		end

		if char.Torso:FindFirstChild("Neck") then
			char.Torso["Neck"].C0 = char.Torso["Neck"].C0:lerp(origNeck, 0.1)
		end
	end
end)

for i,v in pairs(char:GetChildren()) do
	if v:IsA("Tool") then
		if not v:FindFirstChild("HoldArmsStill") then
			IsEquipped = true
		end
	end
end

char.ChildAdded:Connect(function(child)
	if child:IsA("Tool") then
		if not child:FindFirstChild("HoldArmsStill") then
			IsEquipped = true
		end
	end
end)

char.ChildRemoved:Connect(function(child)
	if child:IsA("Tool") then
		IsEquipped = false
	end
end)

game.ReplicatedStorage.Look.OnClientEvent:Connect(function(PlrAgain, neckCFrame, RsCFrame, LsCFrame)
	local Neck = PlrAgain.Character.Torso:FindFirstChild("Neck", true)
	local Rs = PlrAgain.Character.Torso:FindFirstChild("Right Shoulder", true)
	local Ls = PlrAgain.Character.Torso:FindFirstChild("Left Shoulder", true)

	if Neck then
		Neck.C0 = neckCFrame
	end

	if Rs then
		Rs.C0 = RsCFrame
	end

	if Ls then
		Ls.C0 = LsCFrame
	end
end)

while wait(2) do -- you can change here if you want
	game.ReplicatedStorage.Look:FireServer(char.Torso["Neck"].C0, char.Torso["Right Shoulder"].C0, char.Torso["Left Shoulder"].C0)
end
7 Likes

thanks a lot of, give for 1 heart
If you can fix this please help me

2 Likes

@thebrickplanetboy can you make script Tool follow mouse like this but it’s R15 please, i really need it, thank you, if you can help me this too:

2 Likes

@thebrickplanetboy can i have 1 script tool follow mosue but it’s R15 please, I really need it.

1 Like

try to use: Realism — Make your games feel more immersive!
sorry for the delay bc of school

1 Like