Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local weaponHandler = {
- debugmode = true
- }
- --Modules
- local spring = require(script:WaitForChild("SpringModule"))
- local fastcast = require(game.ReplicatedStorage:WaitForChild("Values"):WaitForChild("FastCast"))
- local services = require(script.Parent.RevolutionaryServices)
- local cs = require(script.Parent.CustomVariable)
- --Services
- local tweenService = services.tweenService
- --Functions
- local random = Random.new()
- --Variables
- local inChat
- local hitParticlesEnabled
- local currentWeapon
- local savedWeapon
- local lastHealth = 100
- local movements = {
- default = game.ReplicatedStorage.Values.WalkingSpeed.Normal.Value;
- aiming = game.ReplicatedStorage.Values.WalkingSpeed.Aiming.Value;
- running = game.ReplicatedStorage.Values.WalkingSpeed.Running.Value;
- crouching = game.ReplicatedStorage.Values.WalkingSpeed.Crouching.Value
- }
- local concreteSounds = {
- [1] = "rbxassetid://3689488418";
- [2] = "rbxassetid://3689488700";
- [3] = "rbxassetid://3689489022";
- [4] = "rbxassetid://3689489347";
- }
- local plasticSounds = {
- [1] = "rbxassetid://3689396192";
- [2] = "rbxassetid://3689396705";
- [3] = "rbxassetid://3689397197";
- }
- local metalSounds = {
- [1] = "rbxassetid://3689482778";
- [2] = "rbxassetid://3689483148";
- [3] = "rbxassetid://3689483453";
- [4] = "rbxassetid://3689483722";
- [5] = "rbxassetid://3689484031";
- [6] = "rbxassetid://3689484356";
- }
- local woodSounds = {
- [1] = "rbxassetid://3689542185";
- [2] = "rbxassetid://3689542521";
- [3] = "rbxassetid://3689542840";
- [4] = "rbxassetid://3689543089";
- [5] = "rbxassetid://3689543346";
- }
- local glassSounds = {
- [1] = "rbxassetid://3689485735";
- [2] = "rbxassetid://3689485998";
- [3] = "rbxassetid://3689486291";
- [4] = "rbxassetid://3689486556";
- }
- local dirtSounds = {
- [1] = "rbxassetid://3689528116";
- [2] = "rbxassetid://3689528507";
- }
- local materials = {
- { material = Enum.Material.Concrete, effect = "Rocks"; sounds = concreteSounds };
- { material = Enum.Material.Grass, effect = "Dust"; sounds = dirtSounds };
- { material = Enum.Material.Wood, effect = "Dust"; sounds = woodSounds };
- { material = Enum.Material.CorrodedMetal, effect = "Sparks"; sounds = metalSounds };
- { material = Enum.Material.Brick, effect = "Rocks"; sounds = concreteSounds };
- { material = Enum.Material.Sand, effect = "Dust"; sounds = dirtSounds };
- { material = Enum.Material.Metal, effect = "Sparks"; sounds = metalSounds };
- { material = Enum.Material.Neon, effect = "NeonSpecific"; sounds = metalSounds };
- { material = Enum.Material.Cobblestone, effect = "Rocks"; sounds = concreteSounds };
- { material = Enum.Material.Pebble, effect = "Dust"; sounds = concreteSounds };
- { material = Enum.Material.SmoothPlastic, effect = "Dust"; sounds = plasticSounds };
- { material = Enum.Material.Fabric, effect = "Dust"; sounds = plasticSounds };
- { material = Enum.Material.Granite, effect = "Rocks"; sounds = concreteSounds };
- { material = Enum.Material.Plastic, effect = "Dust"; sounds = plasticSounds };
- { material = Enum.Material.Slate, effect = "Dust"; sounds = concreteSounds};
- { material = Enum.Material.WoodPlanks, effect = "Dust"; sounds = woodSounds };
- { material = Enum.Material.Foil, effect = "Dust"; sounds = plasticSounds };
- { material = Enum.Material.DiamondPlate, effect = "Sparks"; sounds = metalSounds };
- { material = Enum.Material.Ice, effect = "Dust"; sounds = glassSounds };
- { material = Enum.Material.Glass, effect = "Dust"; sounds = glassSounds };
- { material = Enum.Material.Marble, effect = "Dust"; glassSounds}
- }
- local LeanLeftP = { Value = -0.1 }
- local LeanRightP = { Value = 0.1 }
- local NoState = { Value = 0 }
- local leanLeftP = { CameraOffset = Vector3.new(-1,0,0) }
- local leanRightP = { CameraOffset = Vector3.new(1,0,0) }
- local stateResetP = { CameraOffset = Vector3.new(0,0,0) }
- local crouchInP = { CameraOffset = Vector3.new(0,-1.5,0) }
- local crouchOutP = { CameraOffset = Vector3.new(0,0,0) }
- local aimInP = { Value = 1 }
- local aimOutP = { Value = 0 }
- local tweenProperties = TweenInfo.new(0.3,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)
- local defaultMovement = 0.6
- local aimingMovement = 0.1
- local runningMovement = 2
- local crouchingMovement = 1.5
- local equipping = true
- local canEquip = true
- local canRun = true
- local canAim = true --stops aiming
- local aiming = false
- local running = false
- local canShoot = false
- local canFire = true --different from canshoot, stops loop spam
- local shooting = false
- local reloading = false
- local canReload = true
- local vaulting = false
- local canVault = true
- local crouching = false
- local canCrouch = true
- local walled = false
- local walledVariable = script:WaitForChild("Walled")
- local equipEvent = game.ReplicatedStorage.Equip --for requesting the weapon
- function fireSpark(laser)
- local lastPosition
- local maxDistance = 100
- local curDistance = 0
- local stepDistance = 2.5
- local stepWait = 0
- local currentPos = laser.Position
- local currentNormal = laser.CFrame.LookVector
- local overrideDistance = nil
- local timesBounced = 0.01
- repeat
- local ray = Ray.new(currentPos, currentNormal * (overrideDistance or stepDistance))
- local hit, pos, norm = workspace:FindPartOnRayWithIgnoreList(ray, {script.Parent})
- -- Update laser position:
- laser.Size = Vector3.new(0.05, 0.05, (pos - currentPos).Magnitude - timesBounced / 3)
- laser.CFrame = CFrame.new(currentPos:Lerp(pos, 0.5), pos)
- local oldPos = currentPos
- currentPos = pos
- overrideDistance = nil
- if (hit) then
- timesBounced = timesBounced + 1
- local reflect = (currentNormal - (2 * currentNormal:Dot(norm) * norm))
- currentNormal = reflect
- overrideDistance = stepDistance - (pos - oldPos).Magnitude
- if stepDistance ~= 0 then
- stepDistance = stepDistance - 0.5
- end
- -- return
- else
- laser.CFrame = laser.CFrame * CFrame.Angles(-.1,0,0)
- currentPos = laser.Position
- currentNormal = laser.CFrame.LookVector
- end
- if lastPosition == laser.Position then break end
- lastPosition = laser.Position
- laser.Transparency = 0
- curDistance = (curDistance + (pos - oldPos).Magnitude)
- -- Apply fade effect to laser as it approaches max distance from < 75 studs:
- if (curDistance > (maxDistance - 75)) then
- local d = (curDistance - (maxDistance - 75)) / 75
- laser.Transparency = d
- end
- game:GetService("RunService").RenderStepped:Wait()
- until curDistance >= maxDistance
- -- Done! Destroy laser:
- laser:Destroy()
- end
- function weaponHandler.equip(self,choice)
- local gun = {}
- local killed = false --whether the gun was removed
- local Caster = fastcast.new()
- Caster.Gravity = 40 --Set the values accordingly.
- Caster.ExtraForce = Vector3.new()
- if not canEquip or equipping then wait(0.3) end
- if not choice or typeof(choice) ~= "string" then warn("Choice is not a string, choosing primary.") choice = "Primary" end
- local localPlayer = game.Players.LocalPlayer
- local localCharacter = localPlayer.Character
- local localHumanoid = localCharacter.Humanoid
- local localRoot = localCharacter.HumanoidRootPart
- local localProperties = localPlayer:WaitForChild("Values"):WaitForChild("Properties")
- local localHumanoidState = localCharacter:WaitForChild("State")
- local viewmodel = game.ReplicatedStorage.Viewmodel:Clone()
- local weapon = equipEvent:InvokeServer(choice)
- local weaponProperties = weapon.Properties
- local cameraTarget = viewmodel.Camera
- localPlayer:GetMouse().Icon = "rbxassetid://45312113"
- weapon.Parent = viewmodel
- viewmodel.Parent = workspace
- weapon.MainBody.Hold.Part0 = viewmodel:FindFirstChild("Right Arm")
- for i,v in pairs(viewmodel:GetDescendants()) do
- if v:IsA("Part") or v:IsA("MeshPart") then
- v.CastShadow = false
- end
- end
- local sounds = {
- jump = localRoot.Jump;
- landing = localRoot.Landing;
- crouchSound = localRoot.Crouch;
- footPlant = localRoot.FootPlant1;
- footPlantAlt = localRoot.FootPlant2
- }
- local aimingTween = script.AimingTween
- local crouchIn = tweenService:Create(localHumanoid,tweenProperties,crouchInP)
- local crouchOut = tweenService:Create(localHumanoid,tweenProperties,crouchOutP)
- local leanLeft = tweenService:Create(localHumanoid,tweenProperties,leanLeftP)
- local leanRight = tweenService:Create(localHumanoid,tweenProperties,leanRightP)
- local leanOut = tweenService:Create(localHumanoid,tweenProperties,stateResetP)
- local aimIn = tweenService:Create(aimingTween,tweenProperties,aimInP)
- local aimOut = tweenService:Create(aimingTween,tweenProperties,aimOutP)
- local leanVLeft = tweenService:Create(script:WaitForChild("Lean"),tweenProperties,LeanLeftP)
- local leanVRight = tweenService:Create(script:WaitForChild("Lean"),tweenProperties,LeanRightP)
- local LeanVOut = tweenService:Create(script:WaitForChild("Lean"),tweenProperties,NoState)
- local wallIn = tweenService:Create(script:WaitForChild("Walled"),tweenProperties,{ Value = 2 })
- local wallOut = tweenService:Create(script:WaitForChild("Walled"),tweenProperties,{ Value = 0 })
- local Spring = spring:create(3.5,200,25,2)
- local CameraSpring = spring:create(8,100,6,4)
- local IdleSpring = spring:create(8,100,6,4)
- local CamOffsetSpring = spring:create(3.5,200,25,2)
- local localVaultAnim = viewmodel.Humanoid:LoadAnimation(game.ReplicatedStorage.Values.PlayerAnims.VaultLocal)
- local serverVaultAnim = game.ReplicatedStorage.Values.PlayerAnims.VaultBig
- local equipAnim = viewmodel.Humanoid:LoadAnimation(weaponProperties.Equip.Client)
- local idleAnim = viewmodel.Humanoid:LoadAnimation(weaponProperties.Idle.Client)
- local aimAnim = viewmodel.Humanoid:LoadAnimation(weaponProperties.Aim.Client)
- local runAnim = viewmodel.Humanoid:LoadAnimation(weaponProperties.Running.Client)
- local fireAnim = viewmodel.Humanoid:LoadAnimation(weaponProperties.Fire.Client)
- local fireAim = viewmodel.Humanoid:LoadAnimation(weaponProperties.AimShot.Client)
- local magSwitchAnim = viewmodel.Humanoid:LoadAnimation(weaponProperties.MagSwitch.Client)
- local pullBoltAnim = viewmodel.Humanoid:LoadAnimation(weaponProperties.BoltBack.Client)
- local showAnim
- local serverAnimations = {}
- local showExists = weaponProperties:FindFirstChild("Show")
- if showExists then
- showAnim = viewmodel.Humanoid:LoadAnimation(showExists.Client)
- else
- warn("No showcase animation added for "..weapon.Name..", continuing")
- end
- local flagged = false --for making bobble work for the first update loop
- local jumpHeight = 0
- local controlsEnabled = false --enables all module functions
- local broken = false --if aiming was broken
- local distanceToGoal = 15 --for aiming, how far from end of lerp
- local movementStart = 1 --for linearly increasing the movement bobbing when you start moving
- local relativeCamSpeed --WASD movement signifier, velocity relative to root
- local moving = false --controlled by velocity magnitude
- local runUpdateLoop = true --repurposed to not move the viewmodel if not true
- local ranLastFrame = true --for avoiding the tilt glitch
- local useCustomOffset = false --to use custom offset
- local customOffset --the custom offset itself
- local canUnAim = true
- local loopBroken = false
- --ViewBobbing values for OnUpdate()
- local dt = 0 --deltatime for onupdate() viewmodel()
- local tiltBobble = 0 --tiltbobble, removed from bobble vector3 for visual weapon recoil
- local idleBobble
- local springDivider = 1
- local mouseDelta
- local deltaX
- local deltaY
- local bobbleX = 0
- local bobbleY = 0
- local bobble = Vector3.new(0,0,0)
- local camTilt = Vector3.new() --for smooth cameratilt
- --Custom enums
- local regular = false
- local custom = true
- local ammo = localProperties:FindFirstChild(choice.."Ammo").Value
- local rpm = weaponProperties.RPM.Value
- local recoilx = weaponProperties.RecoilX.Value
- local recoily = weaponProperties.RecoilY.Value
- local bulletVelocity = weaponProperties.BulletVelocity.Value
- local permag = weaponProperties.PerMag.Value
- local leaningStates = {
- left = false,
- right = false
- }
- local canLean = true
- local leaning
- local function onRayHit(hitPart, hitPoint, normal, material, bullet)
- if hitPart then
- spawn(function()
- local identity = bullet.Identity.Value
- while not identity do identity = bullet.Identity.Value wait() end
- bullet:Destroy()
- local response,warning = game.ReplicatedStorage.HitEvent:InvokeServer(hitPart,hitPoint,tonumber(identity))
- if response then if warning then warn(response) else print(response) end end
- end)
- end
- if hitPart then
- local sparkDirection = CFrame.new(hitPoint, hitPoint + normal)
- local effectType
- local playerHit = (hitPart.Parent:FindFirstChild("Humanoid") or hitPart.Parent.Parent:FindFirstChild("Humanoid"))
- local pointer = game.ReplicatedStorage.Pointer:Clone()
- pointer.Parent = viewmodel
- local function shredDust(originWithNormals)
- if not pointer or not pointer:FindFirstChild("DustParticle") then return end
- local particle
- pointer.CFrame = originWithNormals
- if not playerHit then
- particle = pointer.DustParticle
- particle.Color = ColorSequence.new(hitPart.Color)
- else
- particle = pointer.PlayerParticle
- end
- particle.Enabled = true
- wait(0.16)
- particle.Enabled = false
- wait(3)
- pointer:Destroy()
- end
- for i,v in pairs(materials) do
- if v.material == material then
- effectType = v.effect
- local sound = Instance.new("Sound")
- sound.SoundId = v.sounds[random:NextInteger(1,#v.sounds)]
- sound.Parent = pointer
- sound:Play()
- end
- end
- if playerHit then
- shredDust(sparkDirection)
- elseif effectType == "Sparks" or effectType == "Rocks" then
- spawn(function()
- shredDust(sparkDirection)
- end)
- for i = 1,random:NextNumber(4,8) do
- spawn(function()
- local spark = game.ReplicatedStorage.Spark:Clone()
- local reflect = CFrame.Angles(math.random(-1, 1)/2, math.random(-1, 1)/2, math.random(-1,1)/2)
- spark.Parent = pointer
- pointer.CFrame = sparkDirection
- spark.CFrame = pointer.CFrame:ToWorldSpace(CFrame.new(0,0,-1)) * reflect
- fireSpark(spark)
- end)
- end
- wait(5)
- pointer:Destroy()
- elseif effectType == "Dust" then
- shredDust(sparkDirection)
- elseif effectType == "NeonSpecific" then
- spawn(function()
- for i = 1,25 do
- for i = 1,random:NextNumber(4,8) do
- spawn(function()
- local spark = game.ReplicatedStorage.Spark:Clone()
- local reflect = CFrame.Angles(math.random(-1, 1)/2, math.random(-1, 1)/2, math.random(-1,1)/2)
- spark.Parent = pointer
- pointer.CFrame = sparkDirection
- spark.CFrame = pointer.CFrame:ToWorldSpace(CFrame.new(0,0,-1)) * reflect
- fireSpark(spark)
- end)
- end
- wait(random:NextInteger(1,5))
- end
- end)
- for i = 1,26 do
- if hitPart.Material == Enum.Material.SmoothPlastic then
- hitPart.Material = Enum.Material.Neon
- else
- hitPart.Material = Enum.Material.SmoothPlastic
- end
- game:GetService("RunService").RenderStepped:Wait()
- end
- hitPart.Material = Enum.Material.SmoothPlastic
- end
- end
- end
- local lastID = 0
- local function fireTracer(origin,direction,speed)
- Caster.IgnoreDescendantsInstance = viewmodel
- local bullet = game.ReplicatedStorage.Tracer:Clone()
- bullet.Parent = viewmodel
- local registeredOrigin = origin.CFrame:ToWorldSpace(CFrame.new())
- local directionalCF = CFrame.new(Vector3.new(), direction)
- local direction = (directionalCF * CFrame.fromOrientation(0, 0, random:NextNumber(0, math.pi * 2)) * CFrame.fromOrientation(math.rad(random:NextNumber(0,0.01)), 0, 0)).LookVector
- local myMovementSpeed = (-localRoot.Velocity)
- local modifiedBulletSpeed = (direction * speed) + myMovementSpeed
- bullet.CFrame = CFrame.new(registeredOrigin.Position, registeredOrigin.Position + direction)
- bullet.Trail.Attachment0 = weapon.MainBody.barrel.Attachment
- local IgnoreList = {
- viewmodel,
- localPlayer.Character
- }
- spawn(function()
- local id = lastID + 1
- lastID = lastID + 1
- if lastID >= 10000 then lastID = 0 end
- bullet.Identity.Value = id
- local response,warning = game.ReplicatedStorage.FiringEvent:InvokeServer(localCharacter.Head.CFrame,direction,id)
- if response then if warning then warn(response) else print(response) end end
- end)
- Caster:FireWithBlacklist(registeredOrigin.Position, direction * speed, modifiedBulletSpeed, IgnoreList, bullet)
- end
- local function onRayUpdated(CastOrigin, SegmentOrigin, SegmentDirection, Length, CosmeticBulletObject)
- local BulletLength = CosmeticBulletObject.Size.Z / 2 -- This is used to move the bullet to the right spot based on a CFrame offset
- CosmeticBulletObject.CFrame = CFrame.new(SegmentOrigin, SegmentOrigin + SegmentDirection) * CFrame.new(0, 0, -(Length - BulletLength))
- end
- local function killEffect(i,multiplier)
- game.Lighting.ColorCorrection.Saturation = -(localHumanoid.Health / 100 - localHumanoid.Health / 100 * 2)
- game.Lighting.ColorCorrection.Saturation = game.Lighting.ColorCorrection.Saturation - 1
- game.Lighting.Blur.Size = -(localHumanoid.Health / 2) + 100 / i * multiplier
- game:GetService("RunService").RenderStepped:Wait()
- end
- healthChanged = localHumanoid.HealthChanged:Connect(function()
- if localHumanoid.Health < lastHealth and game.Lighting:FindFirstChild("Blur") then
- lastHealth = localHumanoid.Health
- game.Lighting.Blur.Size = 40 / localHumanoid.Health
- spawn(function()
- CameraSpring:shove(Vector3.new(.5,0,0.3))
- wait(0.1)
- CameraSpring:shove(Vector3.new(-.3,0,-0.2))
- end)
- for i = 1,25 do
- killEffect(i,4)
- end
- elseif game.Lighting:FindFirstChild("Blur") then
- for i = 1,25 do
- killEffect(i,1)
- end
- end
- end)
- local function humanoidChanged()
- if crouching or reloading then
- localHumanoid.Jump = false -- Yes, it's this simple
- end
- end
- local function updateviewmodel(getoffset,typeofoffset)
- mouseDelta = game:GetService("UserInputService"):GetMouseDelta() --for viewmodel movement
- deltaX = mouseDelta.X
- deltaY = mouseDelta.Y
- relativecamspeed = localRoot.CFrame:VectorToObjectSpace(localRoot.Velocity)
- CameraSpring:shove(Vector3.new(-(bobble.Y / 1500),-(bobble.X / 1500),0))
- Spring:shove(relativecamspeed / 2555)
- Spring:shove(Vector3.new(deltaX / 45,-deltaY / 45,0) / springDivider)
- Spring:shove(CFrame.new(bobble.X / 3,bobble.Y / 6,bobble.Z / 6))
- CameraSpring:shove(idleBobble / 255)
- if aiming then
- IdleSpring:shove(idleBobble / 5)
- else
- IdleSpring:shove(idleBobble / 1.1)
- end
- CamOffsetSpring:shove(Vector3.new(relativecamspeed.X / 500,relativecamspeed.Z / 500,-(relativecamspeed.X / 300)))
- local pos = Spring:update(dt)
- local idlePos = IdleSpring:update(dt)
- local offsetPos = CamOffsetSpring:update(dt)
- pos = pos + idlePos
- local offset = workspace.Camera.CFrame:ToWorldSpace(CFrame.new(pos / 2) * CFrame.Angles(-walledVariable.Value / 3 + offsetPos.Y + pos.Y,walledVariable.Value / 2.5 + offsetPos.X + -pos.X,offsetPos.Z + (bobble.X / 50) + tiltBobble / 10) + Vector3.new(walledVariable.Value / 1.5,0,walledVariable.Value / 1.5))
- if not getoffset then --all of this crap is just for aiming, ugh
- local camPos = CameraSpring:update(dt)
- workspace.Camera.CFrame = workspace.Camera.CFrame:ToWorldSpace(CFrame.new(bobble / 25) * CFrame.Angles(camPos.X,camPos.Y,camPos.Z + -script.Lean.Value ) )
- if runUpdateLoop then
- if customoffset and usecustomoffset then --if the camtarget has a custom offset
- cameraTarget.CFrame = customoffset
- else
- cameraTarget.CFrame = offset * weaponProperties.CFrameOffset.Value
- end
- end
- else
- if typeofoffset == regular then
- return offset
- else
- return customoffset
- end
- end
- end
- local function adjustAnimationSpeed(animation,speed)
- animation:AdjustSpeed(speed)
- for i,v in pairs(serverAnimations) do
- if v.Animation.Parent.Name == animation.Name then
- v:AdjustSpeed(speed)
- end
- end
- end
- died = localHumanoid.Died:Connect(function() --when player dies, reset variables
- lastHealth = 100
- controlsEnabled = false
- if viewmodel then
- viewmodel.Parent = nil
- viewmodel = nil
- weapon.Parent = nil
- weapon = nil
- end
- usecustomoffset = false
- customoffset = CFrame.new()
- equipping = true
- canEquip = true
- running = false
- canAim = true --stops aiming
- aiming = false
- canRun = true
- running = false
- canFire = true --different from canshoot, stops fire loop spam
- shooting = false
- reloading = false
- canReload = true
- canCrouch = true
- crouching = false
- leaningState = false
- leaningStates.left = false
- leaningStates.right = false
- script.Lean.Value = 0
- springDivider = 1
- end)
- local function viewmodelVisible(tomakeVisible) --for equipping weapons
- spawn(function()
- local transparency
- if tomakeVisible then
- transparency = 0
- else
- transparency = 1
- end
- local left = viewmodel:FindFirstChild("Left")
- local right = viewmodel:FindFirstChild("Right")
- left.Transparency = transparency
- right.Transparency = transparency
- for i,v in pairs(left:GetChildren()) do
- if v:IsA("Texture") or v:IsA("MeshPart") or v:IsA("Part") then
- v.Transparency = transparency
- end
- end
- for i,v in pairs(right:GetChildren()) do
- if v:IsA("Texture") or v:IsA("MeshPart") or v:IsA("Part") then
- v.Transparency = transparency
- end
- end
- end)
- end
- local function transitionMovement(desiredMovement)
- local Properties = { Value = desiredMovement }
- local TweenProperties = TweenInfo.new(1,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,false,0)
- local tween = tweenService:Create(script.modifier,TweenProperties,Properties)
- tween:Play()
- end
- local function playAnimation(animation,playOnClient,playOnServer,fadeTime,speed) --for playing animations
- if not speed then speed = 1 end --variables that haven't been fed by the f unction are reset
- if not fadeTime then fadeTime = 0 end
- if playOnClient and animation then
- animation:Play(fadeTime,speed)
- end
- if playOnServer and animation then --i f the animation should replicate, run
- local loadedAnim
- if animation:IsA("Animation") then
- loadedAnim = localHumanoid:LoadAnimation(animation)
- else
- loadedAnim = localHumanoid:LoadAnimation(weaponProperties:FindFirstChild(animation.Animation.Parent.Name).Server)
- end
- loadedAnim:Play(fadeTime,speed)
- if animation:IsA("AnimationTrack") then
- animation.KeyframeReached:Connect(function(keyFrameName)
- local audio = weapon.MainBody:FindFirstChild(keyFrameName)
- audio.TimePosition = audio.TimePos.Value
- audio:Play()
- end)
- end
- spawn(function()
- if loadedAnim.Looped then
- table.insert(serverAnimations,loadedAnim)
- local savedcurrentWeapon = currentWeapon
- repeat wait() until currentWeapon ~= savedcurrentWeapon or not loadedAnim.IsPlaying
- loadedAnim:Stop()
- for i,v in pairs(serverAnimations) do
- if v == loadedAnim then
- table.remove(serverAnimations,i)
- end
- end
- else
- table.insert(serverAnimations,loadedAnim)
- loadedAnim.Stopped:Wait()
- for i,v in pairs(serverAnimations) do
- if v == loadedAnim then
- table.remove(serverAnimations,i)
- end
- end
- end
- end)
- end
- end
- local function stopServerAnimation(animname)
- for i,anim in pairs(serverAnimations) do
- if anim.Animation.Parent.Name == animname then
- anim:Stop()
- table.remove(serverAnimations,i)
- end
- end
- end
- -- LOOPS --------------------------------------------------------------------------------------------------------------------------------------
- spawn(function()
- if weaponHandler.debugmode then
- game.Players.LocalPlayer.PlayerGui:WaitForChild("Debug")
- local fps = 0
- local framerate = 0
- local enabled = true
- local dir = game.Players.LocalPlayer.PlayerGui.Debug.Frame
- game:GetService("RunService").RenderStepped:Connect(function()
- fps = fps + 1
- end)
- spawn(function()
- while wait(1) do
- framerate = fps
- fps = 0
- end
- end)
- game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessed)
- if input.KeyCode == Enum.KeyCode.B then
- enabled = not enabled
- dir.Parent.Enabled = enabled
- end
- end)
- while wait(0.2) do
- if killed then break end
- local variables = {
- {name = "ClientFramerate"; var = framerate};
- {name = "InChat"; var = InChat};
- {name = "ammo"; var = ammo};
- {name = "permag"; var = permag};
- {name = "bulletVelocity"; var = bulletVelocity};
- {name = "currentweapon"; var = currentWeapon};
- {name = "lastHealth"; var = lastHealth};
- {name = "flagged"; var = flagged};
- {name = "controlsEnabled"; var = controlsEnabled};
- {name = "aimingbroken/broken"; var = broken};
- {name = "distancetogoal"; var = distanceToGoal};
- {name = "movementstart"; var = movementStart};
- {name = "cameratarget"; var = cameraTarget};
- {name = "relativecamspeed"; var = relativecamspeed};
- {name = "moving"; var = moving};
- {name = "runupdateloop"; var = runUpdateLoop};
- {name = "ranlastframe"; var = ranlastframe};
- {name = "usecustomoffset"; var = usecustomoffset};
- {name = "customoffset"; var = customoffset};
- {name = "aimingtween"; var = aimingTween.Value};
- {name = "canunaim"; var = canUnAim};
- {name = "loopbroken"; var = loopBroken};
- {name = "deltatime"; var = dt};
- {name = "tiltbobble"; var = tiltBobble};
- {name = "springdivider"; var = springDivider};
- {name = "mousedelta"; var = mouseDelta};
- {name = "bobble"; var = bobble};
- {name = "camtilt"; var = camTilt};
- {name = "equipping"; var = equipping};
- {name = "running"; var = running};
- {name = "aiming"; var = aiming};
- {name = "shooting"; var = shooting};
- {name = "reloading"; var = reloading};
- {name = "crouching"; var = crouching};
- {name = "leaning"; var = leaningState};
- {name = "vaulting"; var = vaulting}--]]
- }
- --toaddlater
- --local HitParticlesEnabl
- for i,v in pairs(dir:GetChildren()) do
- if v:IsA("TextLabel") then
- if v.LayoutOrder == 3 then
- v:Destroy()
- end
- end
- end
- if enabled then
- for i,v in pairs(variables) do
- local sample = script.Sample:Clone()
- sample.Text = (v.name.." : "..tostring(v.var))
- sample.Parent = dir
- end
- end
- end
- end
- end)
- onUpdate = game:GetService("RunService").RenderStepped:Connect(function(deltaTime) -- every frame
- dt = deltaTime
- local boolean = localPlayer.PlayerGui:FindFirstChild("chat"):FindFirstChild("InChat")
- if boolean then
- InChat = boolean.Value
- end
- local speed = localHumanoid.WalkSpeed / 150
- local modifier = 0.03
- idleBobble = Vector3.new(math.sin(tick()*5*speed)*modifier, math.sin(tick()*10*speed)*modifier, 0)
- if localHumanoid then
- if localCharacter.Humanoid.JumpHeight > 8 then
- game.Players.localPlayer:Kick("okay, i'm a really bad developer, but i'm not THAT bad.")
- end
- if localCharacter.Humanoid.WalkSpeed > 22 then
- game.Players.localPlayer:Kick("okay, i'm a really bad developer, but i'm not THAT bad.")
- end
- if localHumanoid and localRoot then
- local velocity = localRoot.Velocity --checking if we're moving
- if velocity.Magnitude > 0.2 then
- flagged = false
- moving = true
- else
- moving = false
- end
- local state = localHumanoid:GetState()
- if state == Enum.HumanoidStateType.Freefall then
- if jumpHeight == 0 then
- sounds.jump:Play()
- CameraSpring:shove(Vector3.new(-0.05,0,0.3))
- end
- jumpHeight = jumpHeight - 0.01
- CameraSpring:shove(Vector3.new(0,0,0.01))
- Spring:shove(Vector3.new(0,-0.5,0.1))
- elseif state == Enum.HumanoidStateType.Landed then
- spawn(function()
- sounds.landing:Play()
- CameraSpring:shove(Vector3.new(jumpHeight,0,0) / 2)
- wait(0.1)
- CameraSpring:shove(Vector3.new(-jumpHeight * 2.5,0,0) / 2)
- jumpHeight = 0
- end)
- elseif state == Enum.HumanoidStateType.Climbing then
- end
- if aiming and weapon:FindFirstChild("opticAttachment") then
- if not weapon:FindFirstChild("opticAttachment"):FindFirstChild("reticle") then warn("No reticle detected for the selected optic attachment!") else
- if aiming then
- weapon.opticAttachment.hitMarker.Transparency = 0
- elseif weapon:FindFirstChild("opticAttachment"):FindFirstChild("reticle") then
- weapon.opticAttachment.hitMarker.Transparency = 1
- end
- end
- end
- if not running and not equipping then --if it works. don't touch it.
- local barrelLength = weaponProperties.BarrelLength.Value
- local ignoreList = {
- [1] = viewmodel;
- [2] = localCharacter
- }
- local actualIgnoreList = {}
- for i,v in pairs(ignoreList) do
- for i,v in pairs(v:GetDescendants()) do
- table.insert(actualIgnoreList,v)
- end
- end
- local wallRay = Ray.new(workspace.Camera.CFrame.Position, workspace.Camera.CFrame.LookVector * barrelLength)
- local hitPart,hitPosition = workspace:FindPartOnRayWithIgnoreList(wallRay,{ viewmodel; localCharacter })
- local calc = (hitPosition - weapon.MainBody.offsetCalculator.Position).Magnitude
- if hitPart and not aiming then
- calc = barrelLength - calc
- if calc < 0.3 then walled = false else walled = true end
- calc = math.clamp(calc,0,barrelLength)
- local tween = tweenService:Create(script:WaitForChild("Walled"),tweenProperties,{ Value = calc })
- tween:Play()
- else
- calc = 0
- walled = false
- end
- local tween = tweenService:Create(script:WaitForChild("Walled"),tweenProperties,{ Value = calc })
- tween:Play()
- end
- if viewmodel and weapon and moving and not flagged then
- local now = tick()
- if movementStart > 1 then --for making START of movement smooth
- movementStart = movementStart / 1.8
- if movementStart <= 1 then --if movement value is lower than 0, set to 1
- movementStart = 1
- end
- end
- if ranlastframe and camTilt and relativecamspeed then
- local delta = relativecamspeed - camTilt
- delta = delta / 10
- camTilt = camTilt + delta
- end
- ranlastframe = true
- tiltBobble = -camTilt.X / 10
- local speed = localHumanoid.WalkSpeed / 11
- local modifier = script.modifier.Value
- local workbobble = Vector3.new(math.sin(tick()*5*speed)*modifier, math.sin(tick()*10*speed)*modifier, 0)-- Vector3.new(Bobble_X,Bobble_Y,0) --* math.min(1, velocity.Magnitude / localhumanoid.WalkSpeed) --r not dividing the actual bobbing to not break it
- bobble = workbobble / movementStart
- updateviewmodel()
- elseif viewmodel and weapon and not moving then
- if movementStart <= 25 then --for making END of movement smooth
- movementStart = movementStart + 1
- end
- tiltBobble = tiltBobble * 0.9
- bobble = bobble * 0.9
- camTilt = camTilt * 0.8
- flagged = false
- ranlastframe = false
- updateviewmodel()
- end
- end
- end
- end)
- -- FUNCTIONS --------------------------------------------------------------------------------------------------------------------------------
- controlsEnabled = true
- equipping = true
- canEquip = false
- currentWeapon = choice
- controlsEnabled = true
- function gun.aim(self,toaim)
- if not toaim then toaim = not aiming end
- if not InChat and controlsEnabled and not walled and not running and not reloading and not equipping then
- --if can use functions
- local vignette = game.Players.LocalPlayer.PlayerGui.InGameUI.Vignette --setting properties
- local reticle
- if weapon:FindFirstChild("opticAttachment") then
- reticle = weapon:FindFirstChild("opticAttachment"):FindFirstChild("reticle")
- else
- reticle = weapon.MainBody.reticle
- end
- if not reticle then error(weapon.Name.." has no reticle!") end
- local camera = workspace.Camera
- local i
- local originPoint
- springDivider = 25
- if toaim and not aiming then
- if not canAim then return end
- aiming = true
- canAim = false --can't aim so the tweens don't break
- playAnimation(aimAnim,false,true,0.3) --replication
- usecustomoffset = true --use custom offset to offset camera using lerping
- if crouching then
- localHumanoid.WalkSpeed = movements.crouching
- else
- localHumanoid.WalkSpeed = movements.aiming --make the player slow
- end
- transitionMovement(aimingMovement)
- originPoint = (viewmodel.Camera.Position - workspace.Camera.CFrame.Position)
- if aimingTween.Value == 1 then aimingTween.Value = 0 end --if value is at end set it back to beginning
- sounds.crouchSound:Play()
- aimIn:Play() --play aimtweening tween
- AIMLOOP = game:GetService("RunService").RenderStepped:Connect(function()
- i = script.AimingTween.Value
- if i ~= 1 and aiming then
- vignette.ImageTransparency = 1 - i
- camera.FieldOfView = camera.FieldOfView - (1 - i)
- viewmodel.Camera.CFrame = workspace.Camera.CFrame:ToWorldSpace(CFrame.new(originPoint)) -- CFrame.new(originpoint,camera.CFrame.LookVector)
- cameraTarget = reticle --somehow fixes all the issues if you set it on every frame
- customoffset = reticle.CFrame:Lerp(updateviewmodel(true,regular),i) --lerp offset to viewmodel position
- elseif i == 1 and aiming then
- canAim = true
- viewmodel.Camera.CFrame = workspace.Camera.CFrame:ToWorldSpace(CFrame.new(originPoint)) -- CFrame.new(originpoint,camera.CFrame.LookVector)
- --cameraTarget = reticle --somehow fixes all the issues if you set it on every frame
- customoffset = reticle.CFrame:Lerp(updateviewmodel(true,regular),i) --lerp offset to viewmodel position
- end
- if i == 1 then canAim = true end
- if not aiming and i == 1 then AIMLOOP:Disconnect() end
- end)
- elseif aiming then
- if not canAim then return end
- aiming = false
- canAim = false --can't aim, like last time
- stopServerAnimation("Aim")
- playAnimation(idleAnim,false,true)
- originPoint = (reticle.Position - workspace.Camera.CFrame.Position) --origin point for velocity reset
- if not crouching then
- springDivider = 1
- else
- springDivider = 2
- end
- if aimingTween.Value == 1 then aimingTween.Value = 0 end
- sounds.crouchSound:Play()
- aimIn:Play()
- UNAIMLOOP = game:GetService("RunService").RenderStepped:Connect(function()
- if usecustomoffset then
- i = script.AimingTween.Value
- if i ~= 1 and not aiming then
- vignette.ImageTransparency = i
- camera.FieldOfView = camera.FieldOfView + (1 - i)
- end
- reticle.CFrame = workspace.Camera.CFrame:ToWorldSpace(CFrame.new(originPoint))
- cameraTarget = viewmodel.Camera --somehow fixes all the issues if you set it on every frame
- customoffset = viewmodel.Camera.CFrame:Lerp(updateviewmodel(true,regular),i) --lerp offset to viewmodel position
- if i == 1 then canAim = true usecustomoffset = false end
- else
- UNAIMLOOP:Disconnect()
- end
- end)
- if not crouching then
- localHumanoid.WalkSpeed = movements.default
- transitionMovement(defaultMovement)
- else
- transitionMovement(crouchingMovement)
- localHumanoid.WalkSpeed = movements.crouching
- end
- end
- end
- end
- function gun.getWeapon()
- return currentWeapon
- end
- function gun.leanLeft()
- if not running and not crouching and not inChat then
- if leaningStates.right then gun:leanRight() end
- leaningStates.left = not leaningStates.left
- if leaningStates.left then
- localHumanoidState.Value = "LeanLeft"
- leaningState = true
- leanVLeft:Play()
- leanLeft:Play()
- else
- LeanVOut:Play()
- leanOut:Play()
- leaningState = false
- localHumanoidState.Value = "None"
- end
- end
- end
- function gun.leanRight()
- if not running and not crouching and not InChat then
- if leaningStates.left then gun:leanLeft() end
- leaningStates.right = not leaningStates.right
- if leaningStates.right then
- leanVRight:Play()
- leanRight:Play()
- leaningState = true
- localHumanoidState.Value = "LeanRight"
- else
- LeanVOut:Play()
- leanOut:Play()
- leaningState = false
- localHumanoidState.Value = "None"
- end
- end
- end
- function gun.run(self,toRun)
- if leaningStates.left then gun:leanLeft() end
- if leaningStates.right then gun:leanRight() end
- if crouching then gun:crouch() end
- if aiming then gun:aim() end
- if not inChat and controlsEnabled and not equipping and not crouching and not aiming and not shooting and canRun and not reloading then
- if toRun and moving then
- running = true
- playAnimation(runAnim,true,true,0)
- transitionMovement(runningMovement)
- localHumanoid.WalkSpeed = movements.running
- while runAnim.TimePosition <= weaponProperties.Running.StopAt.Value + 0.01 do wait(0.001) end
- if not running then return end
- adjustAnimationSpeed(runAnim,0)
- else
- running = false
- transitionMovement(defaultMovement)
- localHumanoid.WalkSpeed = movements.default
- adjustAnimationSpeed(runAnim,1)
- runAnim.Stopped:Wait()
- stopServerAnimation("Running")
- end
- end
- end
- function gun.fire(self,tofire)
- --if not tofire then tofire = not shooting end
- if not inChat and not running and not equipping and canShoot and weapon and not reloading then
- if ammo > 0 then
- shooting = tofire
- if shooting and canFire then
- local i = 1
- repeat
- if i < 3 then
- i = i + 0.2
- end
- canFire = false
- FireWeapon(i)
- local desiredwaittime = (60/rpm)
- local currentwaittime = 0
- wait(60/rpm)
- canFire = true
- until not canShoot or not shooting or not weaponProperties.Automatic.Value or ammo == 0
- shooting = false
- end
- else
- if not tofire then
- local sound = weapon.MainBody.barrel.empty:Clone()
- Spring:shove(Vector3.new(0.1,0.1,0.1))
- sound.Parent = workspace.Camera
- sound:Play()
- wait(5)
- sound:Destroy()
- end
- end
- end
- end
- function FireWeapon(i)
- if not weapon:FindFirstChild("MainBody") then warn("No mainbody part detected") return end
- ammo = ammo - 1
- if ammo > permag then
- ammo = permag
- end
- local directory = weapon.MainBody.barrel
- for i,v in pairs(directory:GetChildren()) do
- if v.Name == "MuzzleFlash" then
- spawn(function()
- v.Transparency = NumberSequence.new( v.OnTransparency.Value )
- wait(0.05)
- v.Transparency = NumberSequence.new( 1 )
- end)
- elseif v.Name == "Smoke" and not v.Enabled then
- spawn(function()
- v.Enabled = true
- repeat wait() until not shooting
- v.Enabled = false
- end)
- end
- end
- local sound = directory.fire:Clone()
- sound.Parent = workspace.Camera
- sound:Play()
- spawn(function()
- wait(sound.TimeLength + 2)
- sound:Destroy()
- end)
- local random = Random.new()
- local X = random:NextNumber(-recoilx,recoilx) / 3
- local Y = recoily
- local recoil = Vector3.new(Y,X,0) --stupid order because CFrame.Angles
- local recoilEquasion = (recoil * math.random(1,1.9) ) / i
- if crouching then recoilEquasion = recoilEquasion / 1.5 end
- if aiming then
- recoilEquasion = recoilEquasion / 2
- spawn(function()
- CamOffsetSpring:shove(Vector3.new(2,math.random(-2,2),math.random(-2,2)))
- end)
- end
- CameraSpring:shove(recoilEquasion)
- spawn(function()
- wait(0.01)
- CameraSpring:shove(-(recoilEquasion / 1.1))
- end)
- if not aiming then
- Spring:shove(recoil * 10)
- else
- Spring:shove(recoil / 15)
- end
- if not aiming then
- Spring:shove(Vector3.new(X * 2,Y * 2,0))
- end
- if aiming then
- fireTracer(workspace.Camera,workspace.Camera.CFrame.LookVector,bulletVelocity)
- else
- local ray = Ray.new(workspace.Camera.CFrame.Position,workspace.Camera.CFrame.LookVector * 100000)
- local list = {
- localCharacter;
- viewmodel
- }
- local hitPart,hitPos = workspace:FindPartOnRayWithIgnoreList(ray,list)
- weapon.MainBody.barrel.CFrame = CFrame.new(weapon.MainBody.barrel.CFrame.Position,hitPos)
- fireTracer(weapon.MainBody.barrel,weapon.MainBody.barrel.CFrame.LookVector,bulletVelocity)
- end
- if aiming then
- playAnimation(fireAim,false,true,0.05)
- playAnimation(fireAnim,true,false,0.05)
- else
- playAnimation(fireAnim,true,true,0.05)
- end
- end
- function gun.crouch(tocrouch)
- if leaningStates.left then gun:LeanLeft() end
- if leaningStates.right then gun:LeanRight() end
- if not tocrouch then return end
- if not InChat and canCrouch and controlsEnabled then
- if not running then
- if not crouching then
- crouching = true
- localHumanoid.WalkSpeed = movements.crouching
- if not aiming then
- transitionMovement(defaultMovement)
- springDivider = 2
- end
- sounds.crouchSound:Play()
- crouchIn:Play()
- CameraSpring:shove(Vector3.new(0,0,0.2))
- Spring:shove(Vector3.new(0,-0.3 ,0))
- localHumanoidState.Value = "Crouch"
- else
- if aiming then
- springDivider = 25
- localHumanoid.WalkSpeed = movements.aiming
- transitionMovement(aimingMovement)
- else
- springDivider = 1
- localHumanoid.WalkSpeed = movements.default
- transitionMovement(defaultMovement)
- end
- sounds.crouchSound:Play()
- crouchOut:Play()
- Spring:shove(Vector3.new(0,0.5 ,0))
- CameraSpring:shove(Vector3.new(0,0,0.2))
- localHumanoidState.Value = "None"
- crouching = false
- end
- elseif moving and running then
- print("Slide")
- end
- end
- end
- function gun.reload()
- if aiming then gun:aim() end
- if not InChat and not reloading and not equipping and not shooting and not running and canReload and not aiming and magSwitchAnim then
- reloading = true
- game.ReplicatedStorage.ReloadEvent:FireServer()
- local pullBolt = false
- if ammo < 1 then pullBolt = true end
- playAnimation(magSwitchAnim,true,true)
- ammo = 0
- magSwitchAnim.Stopped:Wait()
- if pullBolt then
- playAnimation(pullBoltAnim,true,true)
- pullBoltAnim.Stopped:Wait()
- end
- ammo = permag
- reloading = false
- end
- end
- function gun.vault()
- if not InChat and canVault and not equipping and not vaulting and not crouching then
- local ignorelist = {
- viewmodel,
- localPlayer.Character
- }
- vaulting = true
- local headray = Ray.new(localCharacter.HumanoidRootPart.Position + Vector3.new(0,3,0) ,(localCharacter.HumanoidRootPart.CFrame.LookVector ).unit * 5)
- local headpart,position = workspace:FindPartOnRayWithIgnoreList(headray,ignorelist)
- local torsoray = Ray.new(localCharacter.HumanoidRootPart.Position + Vector3.new(0,0.7,0),(localCharacter.HumanoidRootPart.CFrame.LookVector).unit * 5)
- local torsopart,_ = workspace:FindPartOnRayWithIgnoreList(torsoray,ignorelist)
- if not headpart and torsopart and running and not shooting and not reloading and not aiming then
- sounds.jump:Play()
- spawn(function()
- CameraSpring:shove(Vector3.new(-0.4,0,0.4))
- wait(0.15)
- CameraSpring:shove(Vector3.new(0.4,0,-0.4))
- end)
- spawn(function()
- for i = 1,15 do --15 is length in ms i = 1,15 = wait(0.15)
- Spring:shove(Vector3.new(0,-1,0))
- wait(0.01)
- end
- end)
- localHumanoid.JumpHeight = 7
- playAnimation(localVaultAnim,true,false,0.1)
- local vault = playAnimation(serverVaultAnim,false,true,0.05,1,"Server")
- wait(0.2)
- localHumanoid.JumpHeight = 3
- vaulting = false
- else
- vaulting = true
- wait(1)
- if vaulting then
- vaulting = false
- end
- end
- end
- end
- function gun.hold(self,tohold)
- if showAnim and not walled then
- if tohold then
- playAnimation(showAnim,true,true,0.2,1)
- else
- showAnim:Stop()
- stopServerAnimation(showAnim)
- end
- end
- end
- function gun.Cleanup()
- died()
- localPlayer:GetMouse().Icon = ""
- end
- function gun.remove(self,newchoice)
- if leaningStates.right then gun:leanRight() end
- if leaningStates.left then gun:leanLeft() end
- if aiming then gun:aim() end
- if newchoice == choice or not viewmodel or not weapon or not equipAnim or shooting or running or reloading or vaulting then return "failed" end
- if equipping or not canEquip then repeat wait() until not equipping end
- equipping = true
- equipAnim.TimePosition = weaponProperties.Equip.StopAt.Value
- for i,anim in pairs(serverAnimations) do
- if anim.Name == "Equip" then
- anim:Stop()
- table.remove(serverAnimations,i)
- end
- end
- adjustAnimationSpeed(equipAnim,1)
- idleAnim:Stop()
- wait(equipAnim.Length - weaponProperties.Equip.StopAt.Value)
- if newchoice == "Primary" then
- localProperties.SecondaryAmmo.Value = ammo
- else
- localProperties.PrimaryAmmo.Value = ammo
- end
- spawn(function()
- while runloop do
- wait()
- Spring:shove(Vector3.new(0,-2,0))
- end
- end)
- wait(0.1)
- runloop = false
- onUpdate:Disconnect() --disconnect all the existing functions
- died:Disconnect()
- healthChanged:Disconnect()
- gun.Parent = nil
- killed = true
- equipping = false
- currentWeapon = newchoice
- if viewmodel then
- viewmodel:Destroy()
- end
- return "finished"
- end
- --rest of equipping continues here
- if leaningStates.right then gun:leanRight() end
- if leaningStates.left then gun:leanLeft() end
- if crouching then
- localHumanoid.WalkSpeed = movements.crouching
- else
- localHumanoid.WalkSpeed = movements.default
- end
- playAnimation(equipAnim,true,true,0)
- local i = 0
- while equipAnim.TimePosition < weaponProperties.Equip.StopAt.Value do
- if equipAnim.TimePosition > 0 then
- viewmodelVisible(true)
- end
- if i == 1 then break end
- i = i --+ 0.01
- game:GetService("RunService").RenderStepped:Wait()
- end
- adjustAnimationSpeed(equipAnim,0)
- playAnimation(idleAnim,true,true,0.1,1)
- equipping = false
- canEquip = true
- canShoot = true
- controlsEnabled = true
- Caster.LengthChanged:Connect(onRayUpdated)
- Caster.RayHit:Connect(onRayHit)
- return gun
- end
- return weaponHandler
Add Comment
Please, Sign In to add comment