If Statement Not Working

This is supposed to teleport players at a certain point. It does not work. No errors. The if statement seems to be fulfilled but it does not run. I typed "print(“All good”) a line after the if statement. Did not run when the requirements were met.

local part = script.Parent
local timerTextLabel = part.SurfaceGui.TextLabel
local playerTextLabel = part.SurfaceGui2.TextLabel2
local TeleportService = game:GetService("TeleportService")
local playersInLobby = part.PlayersInLobbyValue

part.Touched:Connect(function(hit)
	local findhumanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
	local findvalue = hit.Parent:FindFirstChild("InLobbyValue")
	if findhumanoid then
		if findvalue.Value == true then
			return
		else
			hit.Parent.HumanoidRootPart.CFrame = workspace.Teleporter1EnterPart.CFrame
			findvalue.Value = true
			playersInLobby.Value += 1
			playerTextLabel.Text = "".. playersInLobby.Value .. "/4"
		end
	end
end)

playersInLobby.Changed:Connect(function()
	if playersInLobby.Value > 0 then
		for i = 10, 0, -1 do
		wait(1)
			timerTextLabel.Text = i
		end
	end
end)
			
			
timerTextLabel:GetPropertyChangedSignal("Text"):Connect(function()
	if timerTextLabel.Text == 0 then --This is when the code stops working. Everything before this worked.
		for i, v in pairs(game:GetService("Teams").Lobby1:GetPlayers()) do
			TeleportService:Teleport(9150111783, v)
		end
	end
end)

maybe use FindFirstChildOfClass instead?

local findhumanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
1 Like

Its the same, except IsA also accepts base class.
Part:IsA("BasePart") -- true
Part:IsA("Part") -- true

2 Likes

the text is a string not a number. You should do this instead

if timerTextLabel.Text == "0" then
2 Likes

Darn, you beat me to it.

I vouch!

However, doesn’t it need parentheses, like this;
(“0”)

2 Likes

No it does not. I don’t know where some people got that from.

Even this is possible

game:GetService'RunService' -- Omitting the parenthesis
2 Likes

Of course I made a typo. I made this same mistake a week ago and went to the dev forum and now I am doing it again. Sorry for the inconvenience.

1 Like