Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ____ __
- /\ _`\ /\ \
- \ \ \L\_\ _ __ __ ___ ___ __ __ __ __ ___ _ __ \ \ \/'\
- \ \ _\//\`'__\ /'__`\ /' __` __`\ /'__`\ /\ \/\ \/\ \ / __`\ /\`'__\ \ \ , <
- \ \ \/ \ \ \/ /\ \L\.\_ /\ \/\ \/\ \ /\ __/ \ \ \_/ \_/ \/\ \L\ \\ \ \/ \ \ \\`\
- \ \_\ \ \_\ \ \__/.\_\\ \_\ \_\ \_\\ \____\ \ \___x___/'\ \____/ \ \_\ \ \_\ \_\
- \/_/ \/_/ \/__/\/_/ \/_/\/_/\/_/ \/____/ \/__//__/ \/___/ \/_/ \/_/\/_/
- Written by sen_trix
- Copyright <2020> <sen_trix>
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- --]]
- local Player = game.Players.LocalPlayer
- local Character
- -- [[ Services ]] --
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local RunService = game:GetService("RunService")
- local UserinputService = game:GetService("UserInputService")
- local Camera = workspace.CurrentCamera
- local gun = {
- inventory = {
- "UMP-45"; -- Primary
- "Deagle"; -- Secondary
- "Knife"; -- Mele
- };
- -- States just to tell what the framework is doing
- states = {
- idle = 1;
- aiming = 2;
- reload = 3;
- shoot = 4;
- inspect = 5;
- };
- animationTrack = {
- idle = nil;
- reload = nil;
- };
- -- Weapons
- weapon = nil;
- state = nil;
- module = nil;
- -- CFrames
- mainCF = CFrame.new();
- camCF = CFrame.new();
- }
- local keybind = {
- -- General keybinds that might need to be used
- q = false;
- e = false;
- mouse = {
- mb1 = false; -- Left button
- mb2 = false; -- Right button
- mb3 = false; -- Scroll button
- }
- }
- local function onSpawn()
- -- Load the first weapon in the inventory
- loadWeapon(gun.inventory[1])
- end
- local function update()
- if not gun.weapon then coroutine.yield() end
- gun.weapon:SetPrimaryPartCFrame(Camera.CFrame * gun.mainCF)
- -- [[ States ]] --
- if (gun.state == gun.states.idle)then
- gun.mainCF = gun.mainCF:lerp(gun.module.regularcf,.3)
- if not gun.animationTrack.idle.IsPlaying then
- gun.animationTrack.idle:Play()
- end
- end
- end
- function loadWeapon(weapon)
- local Guns = ReplicatedStorage:WaitForChild("Guns")
- local GunModules = ReplicatedStorage:WaitForChild("GunModules")
- -- Assertation
- assert(Guns[weapon], "Gun doesn't exist in ReplicatedStorage > Guns")
- assert(GunModules[weapon], "Gun doesn't exist in ReplicatedStorage > GunModules")
- -- Update the weapon, state and module
- gun.state = gun.states.idle
- gun.weapon = Guns[weapon]:Clone()
- gun.weapon.Parent = Camera
- gun.module = require(GunModules[weapon])
- -- Load the animation Tracks
- local GunHumanoid = gun.weapon:WaitForChild("Humanoid")
- local animation = Instance.new("Animation",script)
- animation.AnimationId = gun.module.idle
- gun.animationTrack.idle = GunHumanoid:LoadAnimation(animation)
- animation:Destroy()
- end
- RunService.RenderStepped:Connect(update)
- Player.CharacterAdded:Connect(onSpawn)
Advertisement
Add Comment
Please, Sign In to add comment