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)