I’m trying to get all players to present on the runway, but it’s not working properly. This works by setting the status (a) to PLAYERNAME is on the runway!, then teleports the character to the runway, counts their score, and updates the count, if it is above zero say “Next up is…” and then it just goes straight to RunwayOver() and says all contestants have presented but there are one or more contestants that have not presented and their value of HasPresented is not set to true. Here are the relevant functions.
This is really bad coding so excuse the horrible practices, I’ll fix them once i actually get it to a working state
round()
wait(2)
a.Value = "Welcome!"
wait(5)
a.Value = "Choosing judges..."
wait(5)
chooseJudges()
a.Value = "Judges Chosen!"
wait(5)
a.Value = "Moving players and judges..."
wait(5)
teleportJudges()
teleportPlayers()
wait(3)
game.ReplicatedStorage.Countdown:FireAllClients() -- fire a remoteevent
wait(3.0)
a.Value = "Round Start!"
--game.SoundService.airhorn:Play()
for i,v in pairs(game.Workspace.room.Box:GetChildren()) do
v.Transparency = 1
v.CanCollide = false
end
local timer = 10
game.ReplicatedStorage.IsTimer.Value = true
repeat
timer = timer - 1
a.Value = string.format("%d:%02d", math.floor(timer/60), timer%60)
print(timer)
wait(1)
until timer == 0
game.ReplicatedStorage.IsTimer.Value = false
a.Value = "STOP!"
game.SoundService.whistle:Play() -- Replace this later with a localized version (new remote or smth)
for i,v in pairs(game.Players:GetPlayers()) do
if v.Team == teams.Contestants then
v.Character.HumanoidRootPart.Anchored = true
end
end
wait(2)
a.Value = "Teleporting Players..."
wait(1)
for i,v in pairs(game.Players:GetPlayers()) do
if v.Team == teams.Contestants then
v.Character.HumanoidRootPart.Anchored = false
end
end
for i,v in pairs(game.Players:GetPlayers()) do
if v.Team == teams.Contestants then
v.Character:WaitForChild("HumanoidRootPart").CFrame = game.Workspace.Stage.backstage.tele.Attachment.WorldCFrame
end
end
wait(3)
runway()
end```
**RunwayOver()**
```function RunwayOver()
if stop == false then
stop = true
a.Value = "All contestants have walked the runway!"
game.SoundService.victory:Play()
-- Move contestants to random floor points
for _, v in pairs(game.Players:GetPlayers()) do
if v.Team == teams.Contestants then
local Floorpoints = game.Workspace.Stage.Flooring:GetChildren()
local Chosen = Floorpoints[math.random(1, #Floorpoints)]
v.Character.HumanoidRootPart.Position = Chosen.WorldPosition
end
end
wait(5)
a.Value = "Counting score..."
local ScoreTable = {}
for _, v in pairs(game.ReplicatedStorage.FinalScores:GetChildren()) do
table.insert(ScoreTable, v.Name)
table.insert(ScoreTable, v.Value)
end
print(ScoreTable)
local function extractNumbers(tbl)
local numbers = {}
for _, value in ipairs(tbl) do
local numValue = tonumber(value)
if numValue then
table.insert(numbers, numValue)
end
end
return numbers
end
local numbersOnly = extractNumbers(ScoreTable)
local highestNumber = math.max(table.unpack(numbersOnly))
print("Highest number is " .. highestNumber)
print("which has table index number " .. table.find(ScoreTable, highestNumber))
local highestnumberindex = table.find(ScoreTable, highestNumber)
local playernameindex = highestnumberindex - 1
a.Value = "And the winner is..."
game.Workspace.TEMP.Drumroll:Play()
wait(5)
a.Value = ScoreTable[playernameindex] .. "!"
game.Workspace.TEMP["Who's The Winner? (e)"]:Play()
end
end
CountScore()
function CountScore(player)
local JudgeTotals = 0
for _, judge in pairs(game.Players:GetChildren()) do
if judge.Team == teams.Judge then
local contestantVotes = judge.ContestantVotes:FindFirstChild(player.Name)
if contestantVotes then
local PlayerValue = contestantVotes.Value
JudgeTotals = JudgeTotals + PlayerValue
else
warn("ContestantVotes child not found for player " .. player.Name .. " in judge " .. judge.Name)
end
end
end
return JudgeTotals
end
getCount()
local localCount = 0
for _, v in pairs(game.Players:GetPlayers()) do
if v.Team == teams.Contestants and not v.HasPresented.Value then
localCount = localCount + 1
warn(localCount .. " THIS IS THE LOCALCOUNT")
end
end
return localCount
end