First Person Shooter 11-12
Link to Follow Mouse Article (CleverSource)
LocalScript (Killstreaks Frame)
local frame = script.Parent
local perk1 = frame:WaitForChild('P1')
local perk2 = frame:WaitForChild('P2')
local perk3 = frame:WaitForChild('P3')
local player = game.Players.LocalPlayer
local streak = player:WaitForChild('Streak')
local userInput = game:GetService("UserInputService")
streak.Changed:Connect(function()
if streak.Value == 3 then
perk1.BackgroundColor3 = Color3.new(0,255,0)
elseif streak.Value == 5 then
perk2.BackgroundColor3 = Color3.new(0,255,0)
elseif streak.Value == 7 then
perk3.BackgroundColor3 = Color3.new(0,255,0)
end
end)
--ZXC Pressed
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 then
perk1.BackgroundColor3 = Color3.new(255,0,0)
elseif keycode == Enum.KeyCode.X then
perk2.BackgroundColor3 = Color3.new(255,0,0)
elseif keycode == Enum.KeyCode.C then
perk3.BackgroundColor3 = Color3.new(255,0,0)
end
end
end
end
userInput.InputBegan:Connect(perk)
Leaderboard (ServerScriptService)
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
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)
FollowMouse
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head = Character:WaitForChild("Head")
local Neck = Head:WaitForChild("Neck")
local Arm = Character:WaitForChild("RightUpperArm")
local Shoulder = Arm:WaitForChild("RightShoulder")
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local NeckOriginC0 = Neck.C0
local ShoulderOriginC0 = Shoulder.C0
Neck.MaxVelocity = 1/3
RunService.RenderStepped:Connect(function()
local CameraCFrame = Camera.CoordinateFrame
if Character:FindFirstChild("UpperTorso") and Character:FindFirstChild("Head") then
local ArmLookVector = Arm.CFrame.lookVector
local HeadPosition = Head.CFrame.p
if Neck and Shoulder then
if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
local Point = PlayerMouse.Hit.p
local Distance = (Head.CFrame.p - Point).magnitude
local Difference = Head.CFrame.Y - Point.Y
Neck.C0 = Neck.C0:lerp(NeckOriginC0 * CFrame.Angles(-(math.asin(Difference / Distance) ), (((HeadPosition - Point).Unit):Cross(ArmLookVector)).Y, 0), .5 / 2)
Shoulder.C0 = Shoulder.C0:lerp(ShoulderOriginC0 * CFrame.Angles(-(math.asin(Difference / Distance)), (((HeadPosition - Point).Unit):Cross(ArmLookVector)).Y, 0), .5 / 2)
end
end
end
end)