local frame = script.Parent
local perk1 = frame:WaitForChild('P1')
local perk2 = frame:WaitForChild('P2')
local perk3 = frame:WaitForChild('P3')
local streak1 = false
local streak2 = false
local streak3 = false
local userInput = game:GetService('UserInputService')
local player = game.Players.LocalPlayer
local streak = player:WaitForChild('Streak')
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local streaksEvent = ReplicatedStorage:WaitForChild('StreaksEvent')
streak.Changed:Connect(function()
if streak.Value == 3 then
perk1.BackgroundColor3 = Color3.new(0, 255, 0)
streak1 = true
elseif streak.Value == 5 then
perk2.BackgroundColor3 = Color3.new(0, 255, 0)
streak2 = true
elseif streak.Value == 7 then
perk3.BackgroundColor3 = Color3.new(0, 255, 0)
streak3 = true
end
end)
local function perk(input, gameProcessed)
if not gameProcessed then
if input.UserInputType == Enum.UserInputType.Keyboard then
local keycode = input.KeyCode
if keycode == Enum.KeyCode.Z and streak1 then
perk1.BackgroundColor3 = Color3.new(255, 0, 0)
streaksEvent:FireServer('perk1', streak1)
wait(10)
streak1 = false
streaksEvent:FireServer('perk1', streak1)
elseif keycode == Enum.KeyCode.X and streak2 then
perk2.BackgroundColor3 = Color3.new(255, 0, 0)
streaksEvent:FireServer('perk2', streak2)
wait(10)
streak2 = false
streaksEvent:FireServer('perk2', streak2)
elseif keycode == Enum.KeyCode.C and streak3 then
perk3.BackgroundColor3 = Color3.new(255, 0, 0)
streaksEvent:FireServer('perk3', streak3)
wait(10)
streak3 = false
streaksEvent:FireServer('perk3', streak3)
end
end
end
end
userInput.InputBegan:Connect(perk)
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local streaksEvent = ReplicatedStorage:WaitForChild('StreaksEvent')
local function give_streak(player, perk, give)
if give then
if perk == 'perk1' then
player.Character.Humanoid.WalkSpeed = 60
player.Character.Humanoid.JumpPower = 100
elseif perk == 'perk2' then
player.InstaKill.Value = true
elseif perk == 'perk3' then
local force = Instance.new('ForceField')
force.Parent = player.Character
end
else
if perk == 'perk1' then
player.Character.Humanoid.WalkSpeed = 16
player.Character.Humanoid.JumpPower = 50
elseif perk == 'perk2' then
player.InstaKill.Value = false
elseif perk == 'perk3' then
local force = player.Character:FindFirstChildWhichIsA('ForceField')
if force then
force:Destroy()
end
end
end
end
streaksEvent.OnServerEvent:Connect(give_streak)
local function player_check(otherPart)
local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
local shooter = game.Players:FindFirstChild(bullet.Attacker.Value)
if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
if shooter.InstaKill.Value == true then
humanoid:TakeDamage(100)
else
if otherPart.Name == 'Head' then
humanoid:TakeDamage(100)
headshot_sound:Play()
elseif otherPart.Name == "HumanoidRootPart" then
humanoid:TakeDamage(75)
else
humanoid:TakeDamage(30)
end
end
local player = game.Players:FindFirstChild(humanoid.Parent.Name)
if player then
local tag = player:FindFirstChild('Killer')
if tag then
tag.Value = bullet.Attacker.Value
bullet:Destroy()
end
end
end
end
bullet.Touched:Connect(player_check)
local function onPlayerJoin(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = 'leaderstats'
leaderstats.Parent = player
local kills = Instance.new("IntValue")
kills.Value = 0
kills.Name = 'Kills'
kills.Parent = leaderstats
local streak = Instance.new('IntValue')
streak.Value = 0
streak.Name = 'Streak'
streak.Parent = player
local deaths = Instance.new('IntValue')
deaths.Value = 0
deaths.Name = 'Deaths'
deaths.Parent = leaderstats
local killer = Instance.new('StringValue')
killer.Name = 'Killer'
killer.Parent = player
local instaKill = Instance.new('BoolValue')
instaKill.Name = 'InstaKill'
instaKill.Value = false
instaKill.Parent = player
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
-- Ammo drop
local function drop_ammo(death_pos)
wait(1)
local ammo = Instance.new('Part')
ammo.Parent = game.Workspace
ammo.Position = death_pos
ammo.Name = 'Ammo Drop'
ammo.Size = Vector3.new(1,0.5,1)
ammo.BrickColor = BrickColor.new('Black')
local ammoScript = game.ServerStorage:FindFirstChild('AmmoDrop'):Clone()
ammoScript.Parent = ammo
end
-- Health drop
local function drop_health(death_pos)
wait(1)
local health = Instance.new('Part')
health.Parent = game.Workspace
health.Position = death_pos
health.Name = 'Health Drop'
health.Size = Vector3.new(1,0.5,1)
health.BrickColor = BrickColor.new('Really red')
local healthScript = game.ServerStorage:FindFirstChild('HealthDrop'):Clone()
healthScript.Parent = health
end
--Death Tracker
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
drop_ammo(character.HumanoidRootPart.Position)
drop_health(character.HumanoidRootPart.Position)
player.leaderstats.Deaths.Value = player.leaderstats.Deaths.Value + 1
player.Streak.Value = 0
local killerTag = game.Players:FindFirstChild(player.Killer.Value)
if killerTag then
killerTag.leaderstats.Kills.Value = killerTag.leaderstats.Kills.Value + 1
killerTag.Streak.Value = killerTag.Streak.Value + 1
end
end)
end)
end)