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

Variable not read?

Asked by 9 years ago

I had created a couple of variables (with local) but after line 102, ROBLOX doesn't recognize them. What is the problem?

script.Parent.Disabled = true

local playerstorage = game:GetService("Players")
local storage = game:GetService("ServerStorage")
local guifolder = storage.Guis
local players = {}
local holder = game.Workspace:WaitForChild("MapHolder")
local maps = game.Lighting:WaitForChild("Maps")
local message = game.Lighting.Message
local roundtime = 60 * 5


for _, player in pairs(game.Players:GetPlayers()) do
  local humanoid = player.Character:WaitForChild("Humanoid")
  if humanoid and humanoid.Health > 0 then
    table.insert(players, player)
  end
end



message.Value = "Map Being Chosen..."

holder:ClearAllChildren()
wait(2) 

local allmaps = maps:GetChildren()
local newmap = allmaps[math.random(1, #allmaps)]
newmap:Clone().Parent = holder
print 'Map put!'
wait(2)

-- Tell players the map!


if (holder:FindFirstChild("Warehouse")) then

    message.Value = "Map Chosen: Space Warehouse"
    wait(5)
end

    -- Alien Only!
  local alien = table.remove(players, math.random(#players))
  local alieng = guifolder.Alien
  local alieng2 = alieng:Clone()
  alieng2.Parent = alien.PlayerGui

  for _, player in pairs(players) do
    -- only into non-aliens!
    print(player)
    guifolder.Soldier:Clone().Parent = player.PlayerGui
  end

-- TP the players!


for _, player in pairs(game.Players:GetPlayers()) do
  local humanoid = player.Character:WaitForChild("Humanoid")
  if humanoid and humanoid.Health > 0 then
    table.insert(players, player)
  end
end


local spawnmodel =  newmap:WaitForChild("Spawns")
local spawns = spawnmodel:GetChildren()
for _, player in pairs(players) do
    if player and player.Character and #spawns > 0 then
        local Torso = player.Character:WaitForChild("Torso")
        local spawnindex = math.random(1, #spawns)
        local spawn = spawns[spawnindex]
        if spawn and Torso then
            table.remove(spawns, spawnindex)
            Torso.CFrame = CFrame.new(spawn.Position + Vector3.new(0, 3, 0))

                local activetag = Instance.new("StringValue")
                activetag.Name = "activetag"
                activetag.Parent = player.Character         

        end
    end
end

message.Value = "Round In Progress"


-- TIMER

local localtimer = roundtime
while localtimer > 0 do
    wait(1)
    localtimer = localtimer - 1
    message.Value = "Round Time Left: (" .. localtimer .. ")"

    activeplayers = {}
    alienactive = false




    for _, players in pairs(players) do

        if player then
            local character = player.Character
            if character then
                local activetag = character:FindFirstChild("activetag")
                local humanoid = character:FindFirstChild("Humanoid")
                if activetag and humanoid and humanoid.Health > 0 then
                    alienactive = true
                    end
                    table.insert(activeplayers, player)
                end
            end
        end
        if #activeplayers <=1 or not alienactive then
            break
        end
    end
    --[[if localtimer == 0 then
        message.Value = "Time's Up! It's a Draw!"
        for _, player in pairs(players) do
    if player and player.Character then
        local Torso = player.Character:WaitForChild("Torso")
            Torso.CFrame = CFrame.new(Vector3.new(-138.388, 162.94, -146.352) + Vector3.new(0, 3 ,0))
            end
        end
    end --]]



  players = {}


script.Parent.Disabled = false
script.Disabled = true


0
Should be players not player. rexbit 707 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Sometimes, deep into scripts, the functions and loops, etc, cannot access them because they're local. Just remove the local and make it into a global.

Ad

Answer this question