Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hitmeplz = {"Arm1","Arm2","Chest","Face","Leg1","Leg2"}
- local player
- local tool = script.Parent.Parent
- local handle = tool:WaitForChild("Handle")
- local hole = tool:WaitForChild("Hole")
- local flash = hole.FlashGui
- local lastShot = tick()
- local equipped = false
- local reloading = false
- local configs = tool:WaitForChild("Configs")
- local remotes = tool:WaitForChild("Remotes")
- local ammo = configs:WaitForChild("Ammo")
- local reserveAmmo = configs:WaitForChild("ReserveAmmo")
- local magSize = configs:WaitForChild("MagSize")
- local damage = configs:WaitForChild("Damage")
- local fireRate = configs:WaitForChild("FireRate")
- local headMultiplier = configs:WaitForChild("HeadMultiplier")
- local range = configs:WaitForChild("Range")
- local reloadTime = configs:WaitForChild("ReloadTime")
- local canShootRemote = remotes:WaitForChild("CanShoot")
- local canReloadRemote = remotes:WaitForChild("CanReload")
- local reloadRemote = remotes:WaitForChild("Reload")
- local hitRemote = remotes:WaitForChild("Hit")
- local shootRemote = remotes:WaitForChild("Shoot")
- local traceRemote = remotes:WaitForChild("Trace")
- local andagain = remotes:WaitForChild("andbackagain")
- local emptySound = handle:WaitForChild("EmptySound")
- local reloadSound = handle:WaitForChild("ReloadSound")
- local shootSound = handle:WaitForChild("ShootSound")
- local function hit(plr, part)
- if not part then return end
- local character = player.Character or player.CharacterAdded:Wait()
- local rootPart = character:WaitForChild("HumanoidRootPart")
- flash.Enabled = true
- wait(.1)
- flash.Enabled = false
- if rootPart then
- if (rootPart.CFrame.p - part.CFrame.p).magnitude <= range.Value then --//Check range
- local humanoid
- if part.Name == "Handle" then
- humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
- else
- humanoid = part.Parent:FindFirstChild("Humanoid")
- end
- for i,v in pairs(hitmeplz) do
- if part.Parent.Name == v then
- humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
- end
- end
- shootSound:Play()
- if humanoid and humanoid.Health > 0 then --//Do nothing if humanoid is dead
- local newDamage = damage.Value
- if part.Name == "Head" then
- newDamage = newDamage * headMultiplier.Value
- end
- humanoid:TakeDamage(newDamage)
- end
- end
- end
- end
- local function equip()
- equipped = true
- player = game:GetService("Players"):GetPlayerFromCharacter(tool.Parent)
- end
- local function unequip()
- equipped = false
- end
- hitRemote.OnServerEvent:Connect(hit)
- tool.Equipped:Connect(equip)
- tool.Unequipped:Connect(unequip)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement