Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gun = {}
- local model
- local runs = game:GetService("RunService")
- local player = game.Players.LocalPlayer
- local character = player.Character
- local uis = game:GetService("UserInputService")
- local camera =workspace.CurrentCamera
- local speed = character.Humanoid.WalkSpeed/2
- local distance = 0
- local modes = {"AUTO","SEMI"}
- local stats = {}
- stats.Reloading = false
- stats.Aiming = false
- stats.Sprinting = false
- stats.Walking = false
- stats.Busy = false
- stats.MaxAmmo = 31
- stats.MaxMagazines = 6
- stats.Ammo = 30
- stats.Magazines = 6
- stats.gunName = "AK-74M"
- stats.fireMode = modes[1]
- stats.holdcf = CFrame.new(0.2,0,3.6)*CFrame.Angles(0,0,0)
- stats.aimcf = CFrame.new(0,0,3.6)*CFrame.Angles(0,0,0)
- stats.runcf = CFrame.new(0,0,0)*CFrame.Angles(0,0,0)
- local Main = stats.holdcf
- local Walk = CFrame.new()
- local WalkCF = CFrame.new()
- function walks(rs)
- speed = speed*0.85+((character.HumanoidRootPart.Velocity*Vector3.new(1, 0, 1)).magnitude)*0.14
- distance = distance + speed * rs
- local Offset = speed/(character.Humanoid.WalkSpeed*20)
- Walk = CFrame.new(math.sin(distance/2)*Offset/4, math.sin(distance)*Offset/8, 0)
- end
- function cframes()
- if model ~= nil then
- if model.PrimaryPart == nil then
- else
- model.PrimaryPart.CFrame = camera.CFrame*Main*Walk
- if not stats.Sprinting and not stats.Aiming then
- Main = Main:lerp(stats.holdcf,.1)
- character.Humanoid.WalkSpeed = 12
- end
- if stats.Sprinting and not stats.Aiming then
- Main = Main:lerp(stats.runcf,.1)
- character.Humanoid.WalkSpeed = 20
- end
- if not stats.Sprinting and stats.Aiming then
- Main = Main:lerp(stats.aimcf,.1)
- character.Humanoid.WalkSpeed = 6
- end
- end
- end
- end
- runs.RenderStepped:Connect(function(rs)
- walks(rs)
- cframes()
- if character.Head:FindFirstChild("Running") ~= nil then
- local walksound = character.Head:FindFirstChild("Running")
- walksound.SoundId = "rbxassetid://344520856"
- walksound.PlaybackSpeed = 1.2
- walksound.Volume = 0
- end
- end)
- gun.makeGun = function()
- for i, mod in pairs(camera:GetChildren()) do
- if mod ~= script.Name then
- mod:Destroy()
- wait()
- end
- end
- model = script.AK74M:Clone()
- model.Parent = camera
- local hold = Instance.new("Animation")
- hold.AnimationId = "rbxassetid://3484380339"
- local playhold = model.hum:LoadAnimation(hold)
- playhold:Play()
- end
- uis.InputBegan:Connect(function(i,v)
- if not v then
- if i.UserInputType == Enum.UserInputType.MouseButton2 then
- stats.Aiming = true
- uis.MouseIconEnabled = false
- end
- end
- end)
- uis.InputEnded:Connect(function(i,v)
- if not v then
- if i.UserInputType == Enum.UserInputType.MouseButton2 then
- stats.Aiming = false
- uis.MouseIconEnabled = true
- end
- end
- end)
- return gun
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement