-- Server for Client, this is so it works in FE


local update = script:WaitForChild('Update')
local Neck_Original = CFrame.new(0, 1, 0, -1, -0, -0, 0, 0, 1, 0, 1, 0)
function Tween(t,g)
	game.TweenService:Create(t,TweenInfo.new(1,Enum.EasingStyle.Sine,Enum.EasingDirection.Out),g):Play()
end
local SBMode = false
local sine = 0
update.OnServerEvent:connect(function(player, request, mouseposition)
	pcall(function()
	local Torso = player.Character:FindFirstChild('Torso')
	local Arm = Torso:FindFirstChild('Right Shoulder')
	local Arm2 = Torso:FindFirstChild('Left Shoulder')
	if (request == 'Turn') then
		local Offset_O = (Torso.Position.y - mouseposition.y)/100--100 (mouse offset to direction)
		local Mag = (Torso.Position-mouseposition).magnitude/80 --80 (cone of y looking)
		local Offset = Offset_O/Mag
		local NeckWeld = Torso.Neck
			--NeckWeld.C0 = Neck_Original * CFrame.fromEulerAnglesXYZ(Offset-math.rad(90), 0, 0)
	sine = sine + .01
		if Arm ~= nil then
			Arm.C0 = Arm.C0:lerp(CFrame.new(1, 0.5, 0, 0, 0, 1, 0, 1, 0, -1, -0, -0) * CFrame.fromEulerAnglesXYZ(0, 0, -Offset),0.3)
		end
		if Arm2 ~= nil then
if SBMode == false then
				Arm2.C0 = Arm2.C0:lerp(CFrame.new(-1, 0.5, 0, -0, -0, -1, 0, 1, 0, 1, 0, 0) * CFrame.fromEulerAnglesXYZ(0, 0, Offset),0.3)
			else
				
			end
		end
	elseif (request == 'Unequip') then
		sine = 0
		Arm.C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.pi/2, 0) -- reset right arm
		Arm2.C0 = CFrame.new(-1, 0.5, 0) * CFrame.Angles(0, -math.pi/2, 0) -- reset left arm
		Torso.Neck.C0 = Neck_Original
		end
		end)
end)
