game.Players.PlayerAdded:connect(function(plr)
local strVal = Instance.new("StringValue",plr)
strVal.Name = "Team"
end)
if script.ready == true then
print("Game is ready to begin.")
local amount = #game.Players:GetChildren()
print(amount)
if amount == 1 then
print("Amount is 1.")
for _, player in pairs(game.Players:GetPlayers()) do
local randPlr = math.random(1,amount)
local chosen = player[randPlr]
print(chosen)
local PLR = game.Players:FindFirstChild(chosen)
PLR.Team = "Survivor"
end
end
end
This is my script here. The following does not execute for some odd reason.
if amount == 1 then
print("Amount is 1.")
for _, player in pairs(game.Players:GetPlayers()) do
local randPlr = math.random(1,amount)
local chosen = player[randPlr]
print(chosen)
local PLR = game.Players:FindFirstChild(chosen)
PLR.Team = "Survivor"
end
end
The bool value 'ready' inside of the script is true , but it does not execute the above. I cannot explain why the if value isn't being executed. Not even a guess.
Here's the script that actually sets the bool value to true, for a better understanding of the entire idea. This part works perfectly fine.
game.Players.PlayerAdded:connect(function()
local players = #game.Players:GetChildren()
if players == 1 then
print(players.." players are ingame. Preparing match shortly.")
script.Parent.TeamAllocate.ready.Value = true
end
end)
Any help is appreciated. I've gotten back to coding after about a year and I have this killer game idea that people will love... this, obviously, correlates to it. ; -)
Also! Important player values are set to 1 for my own personal testing (since kon has no friends)
