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

[Solved]Help please! ive been trying to debug this for months and its just not working at all?

Asked by 5 years ago
Edited 5 years ago

this is a server script if anyone can help it would be greatly appreciated its a long script though :start() is called by another script and the messages would work if the script didn't break first also no output

local PlayersInGame = {}
local test = true
local ToolPositions = {}
local InGame = false
local Intermission = 5
local State = script.State.Value
local mins = 0
local secs = 0

function HungerGames:Start()
    spawn(function()
        while true do
            wait(15)
        print(State)    
        end
    end)
---------------------------- Starter Setup --------------------------------------
    if workspace:FindFirstChild("HungerGames") then
        workspace.HungerGames.Parent = game.ReplicatedFirst
    end

    for i,v in pairs(game.ReplicatedFirst.HungerGames.ToolSpawns:GetChildren()) do
        table.insert(ToolPositions, v.Position + Vector3.new(0,3,0))
        v:Destroy()
    end

        for i,v in pairs(game.ReplicatedFirst.HungerGames.Spawns:GetChildren()) do
            v.SpawnPoint.Transparency = 1
            v.Script.Disabled = true
        end
    if game:GetService("RunService"):IsStudio() == true then
         test = true
    end
    for i,v in pairs(game.ReplicatedFirst.HungerGames.Items:GetChildren()) do
        v.Handle.Transparency = 1
    end
------------------------ Game Setup (Done Every Time) ----------------------------------
    while true do
        if test then
            repeat wait() until game.Players:FindFirstChild("mattchew1010")
            table.insert(PlayersInGame, game.Players.mattchew1010)
        end
        State = "Startup"
        game.ReplicatedFirst.HungerGames.Parent = workspace
        for i,v in pairs(ToolPositions) do
            if math.random(0,100) > 50 then
                local items = workspace.HungerGames.Items:GetChildren()
                local picked = items[math.random(1, #items)]
                local clone = picked:Clone()
                clone.Handle.Position = v
                clone.Handle.Anchored = false
                clone.Parent = workspace.HungerGames.LooseItems
                clone.Handle.Transparency = 0
            end
        end
        workspace.HungerGames.WeaponsEnabled.Value = false

        wait()
        for i = 1, #PlayersInGame do
            table.remove(PlayersInGame, i)
        end
        State = "Intermission"
        wait(Intermission)
------------------------- Game -----------------------------

        InGame = true
        spawn(function()
            secs = 59
            mins = 19
            while true do
                wait(1)
                if InGame == false then
                    break
                end
                if secs == 0 then
                    mins = mins - 1
                    secs = 59
                end
                workspace.HungerGames.TimeLeft.Value = tostring(mins) .. " : " .. tostring(secs)
            end
        end)
        State = "Game Setup"
        for i,v in pairs(PlayersInGame) do
            if v.Character then
            if not v:FindFirstChild("Location") then
                local loc = Instance.new("StringValue")
                loc.Value = "HungerGames"
                loc.Name = "Location"
                loc.Parent = v
            else
                v.Location.Value = "HungerGames"
            end
            require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Grace Period Ending in 5 Minutes")


                for i, b in pairs(workspace.HungerGames.Spawns:GetChildren()) do
                    if b:FindFirstChild("Claimed") == nil then
                        v.Character:MoveTo(b.SpawnPoint.Position + Vector3.new(0,10,0)) 
                        b.Script.Disabled = false
                        local cl = Instance.new("BoolValue")
                        cl.Name = "Claimed"
                        cl.Parent = b
                        break

                end

            end
            end
        end
        State = "Game Grace Period"
        if test then
            wait(10)
        else
            wait(60 * 5)
        end
        workspace.HungerGames.WeaponsEnabled.Value = true
for i,v in pairs(PlayersInGame) do
    spawn(function()

require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Grace Period Ended, Let the hunt begin!")
wait(20)
State = "Game"
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Game Ends in 20 Minutes")
if test then
            wait(10)
        else
            wait(60 * 10)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Game Ends in 10 Minutes")
if test then
            wait(10)
        else
            wait(60 * 5)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Game Ends in 5 Minutes")
if test then
            wait(10)
        else
            wait(60 * 2)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Game Ends in 3 Minutes")
if test then
            wait(10)
        else
            wait(60 * 3)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Game Ends in 2 Minutes")
if test then
            wait(10)
        else
            wait(60 * 4)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Game Ends in 1 Minutes")
if test then
            wait(10)
        else
            wait(60-5)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("Game Ends in 5 Seconds")
if test then
            wait(1)
        else
            wait(1)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("4")
if test then
            wait(1)
        else
            wait(1)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("3")
if test then
            wait(1)
        else
            wait(1)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("2")
if test then
            wait(1)
        else
            wait(1)
end
require(v.PlayerScripts.Aero.Controllers.ServerMessage):SayWords("1")
end)

end
if test then
    wait(120)
else
    wait(60 * 20)
end

State = "End Game"

        for i,v in pairs(workspace.HungerGames.Spawns:GetChildren()) do
            if v:FindFirstChild("Claimed") then
                v.Claimed:Destroy()
            end
        end
        workspace.HungerGames.Parent = game.ReplicatedFirst
        print("Finished")
        InGame = false
    end
end


1
If nothing is displaying in the output then there could be a if statement preventing the script from continuing. Check the if the statements run by printing. hellmatic 1523 — 5y
0
i thought about doing that but its 200 lines... i guess i can try mattchew1010 396 — 5y
0
omg i found the problem i was just making the script think no one was in the game by deleting everything in the PLayersingame table before the game even started MONTHS for 3 lines to fffffck me up mattchew1010 396 — 5y

Answer this question