First Person Shooter 9-10

HealthDrop (ServerStorage)

local health = script.Parent


local heal_value = 50


local function heal(otherPart)

local humanoid = otherPart.Parent:FindFirstChild('Humanoid')

local player = game.Players:FindFirstChild(otherPart.Parent.Name)

if humanoid and player then

if humanoid.Health > 0 then

health:Destroy()

humanoid.Health = humanoid.Health + heal_value

end

end

end


health.Touched:Connect(heal)


Damage (ServerStorage)

local bullet = script.Parent

local headshot_sound = game.Workspace.HEADSHOT


local function player_check(otherPart)

local humanoid = otherPart.Parent:FindFirstChild('Humanoid')

if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then

if otherPart.Name == 'Head' then

humanoid:TakeDamage(100)

headshot_sound:Play()

else

humanoid:TakeDamage(30)

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)


Leaderboard (SeverScriptService)

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 deaths = Instance.new('IntValue')

deaths.Value = 0

deaths.Name = 'Deaths'

deaths.Parent = leaderstats

end


game.Players.PlayerAdded:Connect(onPlayerJoin)


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.BrickColor = BrickColor.new('Dark stone grey')

local ammoScript = game.ServerStorage:FindFirstChild('AmmoDrop'):Clone()

ammoScript.Parent = ammo

end


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.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


if killerTag then


killerTag.leaderstats.Kills.Value = killerTag.leaderstats.Kills.Value + 1


end

end)

end)

end)


Grenade (StarterPlayerScripts) LocalScript

local userInput = game:GetService("UserInputService")

local player = game.Players.LocalPlayer

local mouse = player:GetMouse()


local ReplicatedStorage = game:GetService('ReplicatedStorage')

local grenadeEvent = ReplicatedStorage:WaitForChild('GrenadeEvent')



local function throw(input, gameProcessed)

if not gameProcessed then

if input.UserInputType == Enum.UserInputType.Keyboard then

local keycode = input.KeyCode

if keycode == Enum.KeyCode.E then

grenadeEvent:FireServer(mouse.Hit.p)

end

end

end

end


userInput.InputBegan:Connect(throw)

GrenadeCreate (ServerScriptService)

local ReplicatedStorage = game:GetService('ReplicatedStorage')

local grenadeEvent = ReplicatedStorage:WaitForChild('GrenadeEvent')


grenadeEvent.OnServerEvent:Connect(function(player, mousePos)

print(mousePos)

local grenade = Instance.new('Part')

grenade.Name = 'Grenade'

grenade.Parent = game.Workspace

grenade.Shape = Enum.PartType.Ball

grenade.Size = Vector3.new(1,1,1)

grenade.BrickColor = BrickColor.new('Dark green')

local speed = 100

grenade.CFrame = CFrame.new(player.Character.Head.Position, mousePos)

grenade.Velocity = grenade.CFrame.lookVector * speed

local grenadeScript = game.ServerStorage:FindFirstChild('GrenadeExplode'):Clone()

grenadeScript.Parent = grenade

end)



GrenadeExplode (ServerStorage)

local grenade = script.Parent


local explode_time = 1

local radius = 10


wait(explode_time)

local explosion = Instance.new('Explosion')

explosion.Parent = workspace

explosion.Position = grenade.Position

explosion.BlastRadius = radius

grenade:Destroy()