Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- -- Variables
- local FrameWork = require(ReplicatedStorage:WaitForChild("ViserGameFramework", 1)) -- Requiring framework.
- local Player = Players.LocalPlayer
- local Mouse = Player:GetMouse()
- local Character = Player.Character or Player.CharacterAdded:Wait()
- local RootPart = Character:WaitForChild("HumanoidRootPart", 1)
- local Hum = Character:WaitForChild("Humanoid", 1)
- local Remotes = ReplicatedStorage:WaitForChild("Remotes", 1)
- local Weapons = Character:WaitForChild("Weapons", 1)
- local Primary = Weapons:WaitForChild("Primary", 1)
- local Secondary = Weapons:WaitForChild("Secondary", 1)
- local Camera = workspace:WaitForChild("Camera", 1)
- local Targ
- local CameraGun
- -- Booleans
- local Pressed = false
- local Crouching = false
- local canViewGun = false
- -- Main
- local Walk = FrameWork.LoadAnim(Hum, 04684551470)
- local Run = FrameWork.LoadAnim(Hum, 4687105406)
- local Idle = FrameWork.LoadAnim(Hum, 4687105932)
- local Crouch = FrameWork.LoadAnim(Hum, 4687132323)
- local CrouchWalk = FrameWork.LoadAnim(Hum, 4687104903)
- local HoldGun = FrameWork.LoadAnim(Hum, 04741271400)
- local HoldMelee = FrameWork.LoadAnim(Hum, 04684554539)
- -- Functions
- local function GiveGun()
- if Mouse.Target ~= nil then
- if Mouse.Target.Parent.Parent.Parent == workspace.Collectibles then
- Targ = Mouse.Target.Parent
- CameraGun = Targ:Clone()
- CameraGun.Parent = Character:WaitForChild("ViewCamera", 1)
- if Targ ~= nil then
- for i,v in pairs(Targ:GetChildren()) do
- if (v:IsA'BasePart') then
- v.Anchored = false
- end
- end
- CameraGun.Handle.CFrame = Camera.CFrame * CFrame.new(1.5, -1, -3)
- end
- if (RootPart.Position - Targ.Handle.Position).Magnitude <= 30 then
- print(Targ.Name)
- if Pressed then
- Remotes.GrabWeapon:FireServer(Targ, Targ.Parent.Name)
- canViewGun = true
- print("Success!")
- end
- end
- end
- end
- wait(1)
- Pressed = false
- end
- local function updateCamera()
- if Targ ~= nil and canViewGun == true then
- CameraGun.Handle.CFrame = Camera.CFrame * CFrame.new(1.5, -1, -3)
- end
- end
- Player.CameraMode = Enum.CameraMode.LockFirstPerson
- -- Updating Camera
- RunService.RenderStepped:Connect(function()
- updateCamera()
- end)
- -- Input
- Hum.Running:Connect(function(Speed)
- if (Walk.IsPlaying == false and Speed > 0.5 and Crouching == false) then
- Run:Stop(0.2)
- Crouch:Stop(0.2)
- CrouchWalk:Stop(0.2)
- Idle:Stop(0.2)
- HoldGun:Play(0.2)
- Walk:Play(0.2)
- if (Walk.IsPlaying == true and Speed > 0.5 and Crouching == true) then
- Run:Stop(0.2)
- Idle:Stop(0.2)
- Walk:Stop(0.2)
- Crouch:Stop(0.2)
- HoldGun:Play(0.2)
- CrouchWalk:Play(0.2)
- end
- elseif (Run.IsPlaying == false and Speed > 16 and Crouching == false) then
- Walk:Stop(0.2)
- Crouch:Stop(0.2)
- CrouchWalk:Stop(0.2)
- Idle:Stop(0.2)
- HoldGun:Play(0.2)
- Run:Play(0.2)
- elseif (Idle.IsPlaying == false and Speed < 0.5 and Crouching == false) then
- Walk:Stop(0.2)
- Crouch:Stop(0.2)
- CrouchWalk:Stop(0.2)
- Run:Stop(0.2)
- HoldGun:Play(0.2)
- Idle:Play(0.2)
- if (Crouching == true and Speed > 0.5) then
- Walk:Stop(0.2)
- Run:Stop(0.2)
- Idle:Stop(0.2)
- CrouchWalk:Stop(0.2)
- HoldGun:Play(0.2)
- Crouch:Play(0.2)
- end
- end
- end)
- UserInputService.InputBegan:Connect(function(Key, Typing)
- if (Key.KeyCode == Enum.KeyCode.E and Typing == false) then
- Pressed = true
- GiveGun()
- end
- if (Key.KeyCode == Enum.KeyCode.LeftControl and Typing == false) then
- if Crouching == false then
- Crouching = true
- elseif Crouching == true then
- Crouching = false
- end
- end
- if (Key.KeyCode == Enum.KeyCode.LeftShift and Typing == false) then
- Hum.WalkSpeed = 32
- end
- end)
- UserInputService.InputEnded:Connect(function(Key, Typing)
- if (Key.KeyCode == Enum.KeyCode.LeftShift and Typing == false) then
- Hum.WalkSpeed = 16
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement