Flashlight vertical movement help in r6

I’m trying to make a script that rotates the right arm in a tool “Flashlight” in StarterPack in the tool but when I do it moves the whole body and randomly makes it fly. it’s so that the flashlight can also move up and down like the camera so it doesn’t only rotate sideways? most ones i tried are broken and rotate the arm inverted and makes a half t pose when equipped.

"Turn" Code - Pastebin.com is the script im looking for but it’s only for r15 and not r6

I don’t really work with cameras, but I updated your code to be more efficient.
Also, the character didn’t fly for me, It was completely normal

local tool = script.Parent
local player = game.Players.LocalPlayer

tool.Equipped:Connect(function()
	print(player.Character.RightUpperArm.RightShoulder.C0)
end)

tool.Unequipped:Connect(function()
	wait(0.1)
	local character = player.Character
	local shoulder = character.RightUpperArm.RightShoulder
	shoulder.CurrentAngle = 0
	shoulder.DesiredAngle = 0
	shoulder.MaxVelocity = 0
	shoulder.C0 = CFrame.new(0.78999,0.58586,0.05672)
end)

while true do
	wait()
	if tool.Parent.Parent == player then continue end
	
	local Character = player.Character
	local Shoulder: Motor6D = Character.RightUpperArm:FindFirstChild("RightShoulder")
	local Root: BasePart = Character:WaitForChild("HumanoidRootPart")
	local CameraDirection = Root.CFrame:ToObjectSpace(workspace.CurrentCamera.CFrame).LookVector.Unit

	Shoulder.C0 = CFrame.new(Shoulder.C0.Position) * CFrame.Angles(math.asin(CameraDirection.Y), -math.asin(CameraDirection.X), 0)
end

You might want to make it turn off when the tool Isn’t equipped.

robloxapp-20241030-0935158.wmv (2.0 MB)

Is the flashlight can collide? If it is then it could be the reason why you character flies.

the r15 one works but making one for r6 is the problem

Sorry, thought you were looking for r15 and had r6. I sometime misinterpret posts
Here’s some code for R6

local tool = script.Parent
local player = game.Players.LocalPlayer

tool.Equipped:Connect(function()
	print(player.Character.Torso["Right Shoulder"].C0)
end)

tool.Unequipped:Connect(function()
	wait(0.1)
	local character = player.Character
	local shoulder: Motor6D = character.Torso["Right Shoulder"]
	shoulder.CurrentAngle = 0
	shoulder.DesiredAngle = 0
	shoulder.MaxVelocity = 0
	shoulder.C0 = CFrame.new(1, 0.5, 0)*CFrame.Angles(0,math.rad(90),0)
end)

while true do
	wait()
	if tool.Parent.Parent == player then continue end

	local Character = player.Character
	local Shoulder: Motor6D = Character.Torso:FindFirstChild("Right Shoulder")
	local Root: BasePart = Character:WaitForChild("HumanoidRootPart")
	local CameraDirection = Root.CFrame:ToObjectSpace(workspace.CurrentCamera.CFrame).LookVector.Unit

	Shoulder.C0 = CFrame.new(Shoulder.C0.Position) * CFrame.Angles(math.asin(CameraDirection.Y), -math.asin(CameraDirection.X), 0) * CFrame.Angles(0,math.rad(90),0)
end

And here’s a video with my results
robloxapp-20241030-1310008.wmv (1.3 MB)
Hope this helps!

1 Like

If the other posts don’t help make sure your flashlight Parts are Massless. Any tool with mass affects Humanoid physics.

tysm :pray:
also is there A way to make it server-side

Well anything affected by a local script about the character will also render to the server.
You can’t really make it server side because it’s accessing the LOCAL CAMERA.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.