Hello! So I was making a lift system (like flood escape) but that isn’t the important part of this problem. It is about this value that keeps returning true when I put ingame = true. So here is my current script:
local function enterLift()
while true do
wait(1)
print(ingame)
if ingame == false then
local lowerbar = stats.SurfaceGui.BackFrame.LowerBar
local upperbar = stats.SurfaceGui.BackFrame.UpperBar
lowerbar:TweenSize(UDim2.new(0, 0,0, 30), "In", "Quint", 5)
upperbar:TweenSize(UDim2.new(0, 0,0, 30), "In", "Quint", 5)
wait(5)
lowerbar.Size = UDim2.new(0, 800,0, 30)
upperbar.Size = UDim2.new(0, 800,0, 30)
if #game.ReplicatedStorage.PlayerInGame:GetChildren() >= 0 then
for i, v in pairs(game.Players:GetPlayers()) do
v.Character.Humanoid.WalkSpeed = 0
if game.ReplicatedStorage.PlayerInGame:FindFirstChild(v.Name) then
game.ReplicatedStorage.Bindables.LoadingFrame:FireClient(v)
else
v.Character.Humanoid.WalkSpeed = 16
end
end
ingame = true
elseif #game.ReplicatedStorage.PlayerInGame:GetChildren() <= 0 then
print("Noone is in lift")
ingame = false
wait(1)
ingame = false
end
elseif ingame == true then
print("Waiting..")
end
end
end
So it always returned true, and for evidence, the output kept spamming:
Please try to indent your code properly for the sake of those reading (and for your own sake, too). With that said, where is ingame defined and what is its purpose?
I believe the problem is that you are checking the number of players in-game incorrectly. This is on the assumption that game.ReplicatedStorage.PlayerInGame is a folder representing a list of items each corresponding to a player.
if #game.ReplicatedStorage.PlayerInGame:GetChildren() >= 0 then
You are checking if the number of players in-game is greater than or equal to zero. What you should do is change this to a greater-than operator >.
ingame is a variable that senses what value it is. It is not debounce, but it helps ‘organize’ things. And it isn’t the players in-game. Also, I already checked and corrected the operator.
You’re never setting ingame to be false. You only detect whether its false and carry out actions, and when you test if it’s true, you never set it to false or do anything.
I do have a feeling this isn’t what you mean, and if so, I’m going to need you to fix your code indentation.