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.
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.
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
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.