wait(10)
print("Test")
while true do
script.Proto.Value = 0
wait(.29)
for _, player in pairs(game.Players:GetChildren()) do
if player.Character.HumanoidRootPart.Position.Y < 80 then
script.Proto.Value += 1
print("Proto Value: "..script.Proto.Value)
end
end
script.Final.Value = script.Proto.Value
print("Amount of players on field: "..script.Final.Value)
end
So that actually made it continue printing, but for the Invasion, Juggernaut, and Classic gamemodes the EndRound script fires even when the value is not 0. But somehow your idea fixed a lot. Thanks!
My guess is that you can’t define these variables like these:
Instead you’d need to do
while wait(.2) do
local stats = game.ServerScriptService.StatusBar
local plrs = game.ServerScriptService["Other Scripts"].PlrCheck.Final
if plrs.Value == 0 then
--Do the rest of the code line
end
end
Yes, but I have a second value called final that only sets to the value of proto after it completes the loop, and the EndRound scripts detects the final value.
CharacterAdded:Wait() instead of adding a 10 second wait wait(10)
Try this code inside the while loop
local Proto = script.Proto
local Final = script.Final
for _, player in pairs(game.Players:GetPlayers()) do
if player.Character.HumanoidRootPart.Position.Y < 80 then
Proto.Value += 1
end
end
Final.Value = Proto.Value
print("Amount of players on field: "..Final.Value)
Ok. So look at the pics of the explorer again, because Final is a second value that gets set to Proto’s value at the end of the loop. Also I don’t think it would take 10 seconds for a character to load in and also it would error if the character did not exist.
I did the same. Final value is being changed to the value of Proto. Sure it won’t take 10 seconds for the character to load but what about those with bad internet?
So I found out that this bug only happens the first time one of a certain 3 gamemodes occur, so I made it so that if it detects 0, it teleports everyone to the lobby so no one gets a win, because no one should techincally be on the field anyways. Thanks for all the help! A special thanks to @JackscarIitt