Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

My Hunger game is not working can you tell me why?

Asked by 9 years ago

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

    local killer = getKillerOfHumanoidIfStillInGame(humanoid)

    handleKillCount(humanoid, player)
    local playersStillInBattle = {}
    for i,child in pairs(game.Players:getChildren()) do
        if child.Alive.Value then
            table.insert(playersStillInBattle, child)
        end
    end
    if #playersStillInBattle <= 1 then
        battle = false
        nameWinner()
        killAllPlayers()
    end
end

end

function getKillerOfHumanoidIfStillInGame(humanoid) -- returns the player object that killed this humanoid -- returns nil if the killer is no longer in the game

-- check for kill tag on humanoid - may be more than one - todo: deal with this
local tag = humanoid:findFirstChild("creator") -- find player with name on tag
if tag ~= nil then
    local killer = tag.Value
    if killer.Parent ~= nil then -- killer still in game
        return killer
    end
end
return nil

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

end

function onPlayerEntered(newPlayer) wait()

    local kills = Instance.new("NumberValue")
    kills.Name = "Kills"
    kills.Value = 0

    local deaths = Instance.new("NumberValue")
    deaths.Name = "Deaths"
    deaths.Value = 0

    local wins = Instance.new("NumberValue")
    wins.Name = "Wins"
    wins.Value = 0

    local Alive = Instance.new("BoolValue")
    Alive.Name = "Alive"
    Alive.Value = false

    while true do
        if newPlayer.Character ~= nil then break end
        wait(5)
    end

    newPlayer.Changed:connect()
        function(property) 
            if property == "Character" and newPlayer.Alive.Value = false then
                print("Player spawned, removing tools")
                for i,tool in pairs(newPlayer.Backpack:getChildren()) do
                    if tool.className == "Tool" or tool.className == "HopperBin" then
                        tool:remove()
                    end
                end
            end
        end
    )

    if newPlayer:findFirstChild("leaderstats") == nil then
        local stats = Instance.new("IntValue")
        stats.Name = "leaderstats"
        kills.Parent = stats
        deaths.Parent = stats
        wins.Parent = stats
        stats.Parent = newPlayer
        Alive.Parent = newPlayer
    else
        kills.Parent = newPlayer
        deaths.Parent = newPlayer
    end

    newPlayer.Alive.Value = false

    for i,tool in pairs(newPlayer.Backpack:getChildren()) do
        if tool.className == "Tool" or tool.className == "HopperBin" then
            tool:remove()
        end
    end

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

1 answer

Log in to vote
0
Answered by 9 years ago

Perhaps in the 1st script, did you define what the name is going to do?

0
Yeah I think so but it is not made by me the script is http://web.roblox.com/item.aspx?setItemId=14504411&avID=233131947 is you want to review it. Scottkid321 5 — 9y
Ad

Answer this question