So I was making a script that has a couple of tables that check for text in a textButton’s name, brought over from a different script. _G.CloneType has worked for me in the past, that shouldn’t be the issue The error is saying ServerScriptService.CountdownManagerScript:68: invalid 'for' limit (number expected, got nil). I don’t know how this variable is resulting as nil. Can somebody explain?
game.Players.PlayerAdded:Connect(function(player)
_G.LocalPlayer = player
end)
local gameState = game.ReplicatedStorage:WaitForChild("GameState")
gameState.Changed:Connect(function()
if gameState.Value == "Intermission" then
game.ReplicatedStorage:WaitForChild("CloneTypeEvent").OnServerEvent:Connect(function(player,cloneType)
_G.CloneType = cloneType
end)
for x=10, 0, -1 do
if x == 0 then
_G.changeToInGameDebounce = false
gameState.Value = "InGame"
_G.changeToInGameDebounce = true
end
local remoteEvent = game.ReplicatedStorage:WaitForChild("TimeUntilNextGameEvent")
remoteEvent:FireAllClients(x)
wait(1)
end
end
if gameState.Value == "InGame" then
if _G.changeToInGameDebounce == false then
local inGameRemoteEvent = game.ReplicatedStorage:WaitForChild("InGameRemoteEvent")
inGameRemoteEvent:FireAllClients()
local numbersOfClonesTable = {
string.find(_G.CloneType,"One"),
string.find(_G.CloneType,"Two"),
string.find(_G.CloneType,"Three"),
string.find(_G.CloneType,"Four"),
string.find(_G.CloneType,"Five"),
string.find(_G.CloneType,"Six"),
string.find(_G.CloneType,"Seven"),
string.find(_G.CloneType,"Eight"),
string.find(_G.CloneType,"Nine"),
string.find(_G.CloneType,"Ten")
}
local typesOfClonesTable = {
string.find(_G.CloneType,"Normal"),
string.find(_G.CloneType,"Baby"),
string.find(_G.CloneType,"Giant")
}
for x=1, #numbersOfClonesTable, 1 do
local number = numbersOfClonesTable[x]
print(number)
if number ~= nil then
_G.numberOfClones = x
print(x)
end
end
for x=1, #typesOfClonesTable, 1 do
local Type = typesOfClonesTable[x]
if Type ~= nil then
_G.cloneType = x
end
end
repeat wait() until _G.LocalPlayer.Character ~= nil
_G.LocalPlayer.Character.Archivable = true
for x = 1, _G.numberOfClones, 1 do
if _G.cloneType == 1 then
local clone = _G.LocalPlayer.Character:Clone()
clone.HumanoidRootPart.Position = Vector3.new(math.random(0,25),9.57,math.random(-83,-25))
clone.Parent = workspace
clone.Name = _G.LocalPlayer.Name .. " Clone"
elseif _G.cloneType == 2 then
local clone = _G.LocalPlayer.Character:Clone()
clone.HumanoidRootPart.Position = Vector3.new(math.random(0,25),9.57,math.random(-83,-25))
clone.Humanoid.HumanoidWidthScale = 0.5
clone.Humanoid.HumanoidHeightScale = 0.5
clone.Parent = workspace
clone.Name = _G.LocalPlayer.Name .. " Clone"
elseif _G.cloneType == 3 then
local clone = _G.LocalPlayer.Character:Clone()
clone.HumanoidRootPart.Position = Vector3.new(math.random(0,25),9.57,math.random(-83,-25))
clone.Humanoid.HumanoidWidthScale = 1.5
clone.Humanoid.HumanoidHeightScale = 1.5
clone.Parent = workspace
clone.Name = _G.LocalPlayer.Name .. " Clone"
end
end
--[[
if _G.CloneType == "TwoNormal" then
print("2 normal clones being made")
repeat wait() until _G.LocalPlayer.Character ~= nil
_G.LocalPlayer.Character.Archivable = true
for x=1, 2, 1 do
local clone = _G.LocalPlayer.Character:Clone()
clone.HumanoidRootPart.Position = Vector3.new(math.random(0,25),9.57,math.random(-82,-25))
clone.Parent = workspace
clone.Name = _G.LocalPlayer.Name .. " Clone"
end
end
--]]
end
end
end)