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

Why is this Main Game Script not Working?

Asked by 10 years ago

So this is a rather large game script that is supposed to manage the game. It doesn't work, and output isn't giving me anything. Can someone please help me?

Here's the script (Yes, everything in the script is defined):

local Maps = game.ServerStorage.Maps
local Mode = script.Mode
local MV = script.Map
local TDM = script.TeamDeathMatchScript
local TS = script.Time.Countdown
local SL = script.ScoreLimit
local msg = Instance.new("Message")
local USMC = game.Workspace.USMCV
local PLA = game.Workspace.PLAV
local Up = script.Time.TimesUp
local Play = script.Playing

while true do
    if USMC.Value == SL.Value or PLA.Value == SL.Value or Up.Value == true then
        script.Time.Hi.Disabled = true
        Play.Value = false
        MV.Value = "None"
        Mode.Value = "None"
        if Mode.Value == "TDM" then
            msg.Parent = game.Workspace
            if USMC.Value > PLA.Value then
                msg.Text = "USMC won!"
            elseif PLA.Value > USMC.Value then
                msg.Text = "PLA won!"
            elseif PLA.Value == USMC.Value then
                msg.Text = "Tie!"
            end
        if Mode.Value == "Domination" then
            msg.Parent = game.Workspace
            if USMC.Value > PLA.Value then
                msg.Text = "USMC won!"
            elseif PLA.Value > USMC.Value then
                msg.Text = "PLA won!"
            elseif PLA.Value == USMC.Value then
                msg.Text = "Tie!"
            end
        end
        if game.Workspace.Map ~= nil then
            game.Workspace.Map:remove()
        end
        msg.Text = "A new battle is beginning!"
        wait(1.5)
        NewMode()
        wait(2)
        NewMap()
        wait(2)
        Play.Value = true
        script.Time.Left.Value = 45
        script.Time.Hi.Disabled = false
    end
    end
end

function NewMode()
    local y = math.random(1,2)
    if y == 1 then
        msg.Text = "Map Chosen: Team Death Match!"
        Mode.Value = "TDM"
    elseif y == 2 then
        msg.Text = "Mode Chosen: Domination!"
        Mode.Value = "Domination"
    end
end

function NewMap()
    local x = math.random(1,2)
    if x == 1 then
        local Building = Maps.Building:clone()
        Building.Parent = game.Workspace
        Building.Name = "Map"
        msg.Text = "Map Chosen: Building!"
        MV.Value = "Building"
        if Mode.Value == "Domination" then
            Building.Flags:remove()
        end
    elseif x == 2 then
        local House = Maps.House:clone()
        House.Parent = game.Workspace
        House.Name = "Map"
        msg.Text = "Map Chosen: House!"
        MV.Value = "House"
        if Mode.Value == "Domination" then
            House.Flags:remove()
        end
    end
end
0
How is it not working? EzraNehemiah_TF2 3552 — 10y
0
It won't do anything. At all. CoolJohnnyboy 121 — 10y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

I'm surprised this isn't giving you an error, but NewMap and NewMode never get defined because of the infinite loop above them. Also, it looks like you have an extra end on line 51.

Looking at the loop itself a little closely, if that first conditional isn't met, the loop never waits, meaning you'll crash the moment the conditional is false. Change while true do to while wait() do to fix that.

I heavily suggest using Destroy instead of remove. Remove is deprecated.

Ad

Answer this question