So the script says that I need to have a individual map (with spawns) and have it stored in lighting.
I also have to have a spawn room with neutral spawns.
I have the msg in workshop
I also have the starter gui
Finally I have a script in work shop and another script in workshop
Hung game script:
local message = game.Workspace.Msg.Value
local Cannon = Script.Cannon
local Tick = Script.Tick
battle = false
function onDiedInBattle(humanoid, player)
local stats = player:findFirstChild("deaths")
if stats ~= nil and battle==true then
local deaths = player.deaths
deaths.Value = deaths.Value + 1
Cannon:Play()
player.Alive.Value = false
message(player.Name.." has died, "..#playersStillInBattle.."remain.")
01 | local killer = getKillerOfHumanoidIfStillInGame(humanoid) |
03 | handleKillCount(humanoid, player) |
04 | local playersStillInBattle = { } |
05 | for i,child in pairs (game.Players:getChildren()) do |
06 | if child.Alive.Value then |
07 | table.insert(playersStillInBattle, child) |
10 | if #playersStillInBattle < = 1 then |
end
function getKillerOfHumanoidIfStillInGame(humanoid)
-- returns the player object that killed this humanoid
-- returns nil if the killer is no longer in the game
2 | local tag = humanoid:findFirstChild( "creator" ) |
4 | local killer = tag.Value |
5 | if killer.Parent ~ = nil then |
end
function handleKillCount(humanoid, player)
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
if killer ~= nil then
local stats = killer:findFirstChild("kills")
if stats ~= nil then
local kills = player.kills
if killer ~= player then
kills.Value = kills.Value + 1
else
kills.Value = kills.Value - 1
end
function onPlayerEntered(newPlayer)
wait()
01 | local kills = Instance.new( "NumberValue" ) |
05 | local deaths = Instance.new( "NumberValue" ) |
09 | local wins = Instance.new( "NumberValue" ) |
13 | local Alive = Instance.new( "BoolValue" ) |
18 | if newPlayer.Character ~ = nil then break end |
22 | newPlayer.Changed:connect() |
24 | if property = = "Character" and newPlayer.Alive.Value = false then |
25 | print ( "Player spawned, removing tools" ) |
26 | for i,tool in pairs (newPlayer.Backpack:getChildren()) do |
27 | if tool.className = = "Tool" or tool.className = = "HopperBin" then |
35 | if newPlayer:findFirstChild( "leaderstats" ) = = nil then |
36 | local stats = Instance.new( "IntValue" ) |
37 | stats.Name = "leaderstats" |
41 | stats.Parent = newPlayer |
42 | Alive.Parent = newPlayer |
44 | kills.Parent = newPlayer |
45 | deaths.Parent = newPlayer |
48 | newPlayer.Alive.Value = false |
50 | for i,tool in pairs (newPlayer.Backpack:getChildren()) do |
51 | if tool.className = = "Tool" or tool.className = = "HopperBin" then |
end
game.Players.ChildAdded:connect(onPlayerEntered)
function killAllPlayers()
for i, player in pairs(game.Players:getChildren()) do
player.Character.Humanoid.Health = 0
player.Alive.Value = false
end
end
function teleportTributes()
Spawns = Map.Spawns:getChildren()
for i, player in pairs do
wait()
S = Spawns[math.random(1, #Spawns)]
player.Character.Humanoid.Walkspeed = 0
player.Character.Humanoid.Health = player.Character.Humanoid.MaxHealth
player.Alive.Value = true
for t,y in pairs(Spawns) do
if y == E then
table.remove(Spawns,t)
end
end
end
countdown()
end
function countdown()
for i = 1, 60 do
message(tostring(60 - i))
wait(.5)
Tick:Play()
end
player.Character.Humanoid.Walkspeed = 16
message("Let the Hunger Games begin!")
end
function chooseMap()
Maps = game.Lighting:getChildren("Maps")
for i = 1, #Maps do
Map:Clone().Parent = game.Workspace
message(Map.Name.." has been selected!")
tools = game.Lighting.Tools
tools:Clone().Parent = Map
tools:MoveTo(Map.Cornucopia:GetCFrame().Position + Vector3.new(0,.3,0))
wait(2)
teleportTributes()
end
end
function beginBattle()
for i, player in pairs(game.Players:getChildren()) do
if player.Character.Humanoid.Health <= 0 then
while true do
if player.Character ~= nil then
if player.Character.Humanoid.Health >= 0 then break end
end
wait()
end
end
print(player.Name.." is now ready for battle.")
player.Character.Humanoid.Died:connect(function() onDiedInBattle(player.Character.Humanoid, player) end)
end
end
function nameWinner()
local winners = {}
function getWinners()
for i,player in pairs(game.Players:getChildren()) do
if player.Alive.Value then
table.insert(winners, player)
end
end
end
getWinners()
if #winners == 1 then
winners[1].leaderstats.Wins.Value = winners[1].leaderstats.Wins.Value + 1
end
end
if #winners == 1 then
message("The winner of The Hunger Games was "..winners[1].Name.."!")
elseif #winners == 0 then
message("Everyone died in this Hunger Games.")
end
end
while true do
if game.Players.NumPlayers >= 2 then
wait(3)
message("Welcome to The Hunger Games by [Your Name Here]!")
wait(2)
message("Transporting all tributes...")
teleportTributes()
message("Let The Hunger Games begin!", 3)
message("The battle will when one winner remains.")
wait(.25)
battle = true
beginBattle()
if #winners = 1 then
battle = false
message("The Hunger Games are now over!")
nameWinner()
killAllPlayers()
else
wait(2)
message("Two Players are needed for the Games :D or ya cant play")
end
wait(3.1)
end
The time script:
l = game:service("Lighting")
while true do
-- increment the time of day and then wait for a while
l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+0.1)
wait(0.01)
end
Please help me.
:D greatly appreciated