Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local UIS = game:GetService("UserInputService")
- local RunService = game:GetService("RunService")
- local Workspace = game:GetService("Workspace")
- local Modules = require(ReplicatedStorage:WaitForChild("Modules"))
- local Network = Modules.Get("Network")
- local InputUtility = Modules.Get("Input")
- local Utility = Modules.Get("Utility")
- local ObjectManager = Modules.Get("ObjectManager")
- local BulletManager = Modules.Get("BulletManager")
- local LocalPlayer = Players.LocalPlayer
- local Mouse = LocalPlayer:GetMouse()
- local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
- local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
- local RootPart = Character:WaitForChild("HumanoidRootPart")
- local Humanoid = Character:WaitForChild("Humanoid")
- local GunGui = PlayerGui:WaitForChild("Gun")
- local CooldownFrame = GunGui:WaitForChild("Cooldown")
- local CooldownBar = CooldownFrame:WaitForChild("Bar")
- local Tool = script.Parent
- local ReloadTime = 1/80
- local LastFired = 0
- local function CanFire()
- return Character.Parent and Humanoid.Health > 0 and os.clock()-LastFired > ReloadTime
- end
- Tool.Activated:Connect(function()
- if not CanFire() then return end
- LastFired = os.clock()
- CooldownFrame.Visible = true
- CooldownBar.Size = UDim2.fromScale(1, 1)
- CooldownBar:TweenSize(UDim2.fromScale(0, 1), Enum.EasingDirection.In, Enum.EasingStyle.Linear, ReloadTime, true, function(DidComplete)
- if not DidComplete then return end
- CooldownFrame.Visible = false
- end)
- while UIS:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
- local BulletOrigin = RootPart.Position
- local BulletDirection = Mouse.Hit.LookVector
- Network.FireTo("Server", "FireGun", BulletOrigin, BulletDirection)
- BulletManager.CreateBullet(BulletOrigin, BulletDirection)
- task.wait(ReloadTime)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement