Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local player = game:GetService'Players'.LocalPlayer
- local playerInputs = game:GetService'UserInputService'
- local connections = {}
- local character = player.Character
- --wfc short for WaitForChild
- local function wfc(parent, child)
- return parent:WaitForChild(child)
- end
- local torso = wfc(character, 'Torso')
- local camera = wfc(workspace, 'Camera')
- --player.CameraMode = Enum.CameraMode.LockedFirstPerson
- --o short for object
- local function o(instanceName)
- local instance = Instance.new(instanceName)
- return (function(properties)
- for property, value in next, properties do
- instance[property] = value
- end
- return instance
- end)
- end
- --v3 short for Vector3
- v3 = Vector3.new
- --cf short for CFrame
- cf = CFrame.new
- --ca short for CFrame Angles
- ca = CFrame.Angles
- --bc short for BrickColor
- bc = BrickColor.new
- --rad short for Radians
- rad = math.rad
- --cos short for Cosine
- cos = math.cos
- --sin short for Sine
- sin = math.sin
- --abs short for Absolute Value
- abs = math.abs
- --
- wfc(character, 'Animate').Disabled = true
- if camera:FindFirstChild('Client') then
- camera.Client:Destroy()
- end
- local clientView = o'Model'{
- Name = 'Client',
- Parent = camera
- }
- local fakeLeftArm = o'Part'{
- Name = 'Fake Left Arm',
- Parent = clientView,
- Anchored = false,
- CanCollide = true,
- TopSurface = 1,
- BottomSurface = 0,
- BrickColor = bc('Wheat'),
- Material = 'SmoothPlastic',
- Size = v3(1, 2, 1)
- }
- local fakeRightArm = fakeLeftArm:Clone()
- fakeRightArm.Name = 'Fake Right Arm'
- fakeRightArm.Parent = clientView
- local weldLA = o'Weld'{
- Name = 'Fake Left Arm Weld',
- Parent = fakeLeftArm,
- Part0 = torso,
- Part1 = fakeLeftArm,
- C0 = cf(-1.5, 0.5, -0.75) * ca(rad(90), 0, 0)
- }
- local weldRA = o'Weld'{
- Name = 'Fake Right Arm Weld',
- Parent = fakeRightArm,
- Part0 = torso,
- Part1 = fakeRightArm,
- C0 = cf(1.5, 0.5, -0.75) * ca(rad(90), 0, 0)
- }
- --
- for i = 0, 360 do
- weldLA.C1 = cf() * ca(rad(i), 0, 0)
- end
- connections['onInput'] = playerInputs.InputBegan:Connect(function(input, onUI)
- --[[
- Enum.UserInputType
- Keyboard, MouseButton1, MouseButton2, MouseButton3, Touch, Gamepad1, MouseWheel
- ]]--
- end)
- connections['deadInput'] = playerInputs.InputEnded:Connect(function(input, onUI)
- end)
- connections['changedInput'] = playerInputs.InputChanged:Connect(function(input, onUI)
- local inputType = input.UserInputType
- if inputType == Enum.UserInputType.MouseMovement then
- local cameraFrame = camera.CoordinateFrame
- local direction = cameraFrame.lookVector
- local yaw = math.atan2(direction.x, -direction.z)
- local pitch = math.atan(math.sqrt(math.pow(direction.x, 2) + math.pow(direction.z, 2)) / direction.y)
- weldLA.C1 = cf() * ca(cos(pitch) * (pitch > 0 and -1 or 1), 0, 0)
- weldRA.C1 = weldLA.C1
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement