Storygame text ignoring teleportation when there are players in the queue

Hi there, I’m a novice dev trying to make a storygame. I ran into another issue where the teleportation function would be ignored even when there are players in the queue:

the code (Parented under the time text label):

while true do 
	for i = 29, 0, -1 do task.wait(1) 
		script.Parent.Text = i 
	end
	if script.Parent.Text == "0" and script.Parent.Parent.Parent.Parent.Players.SurfaceGui.TextLabel.Text == "0" then continue else  --check the status
		game.Workspace.Invwall.Size = Vector3.new(175, 25, 12)  --players cant enter the queue when teleporting
		script.Parent.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel.TextColor3 = Color3.new(0.4, 0, 0) 
		script.Parent.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel.Text = "TELEPORTING"  
		wait(5) 
		game.Workspace.Invwall.Size = Vector3.new(175, 25, 1) script.Parent.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel.Text = "READY"
		script.Parent.Parent.Parent.Parent.Players.SurfaceGui.TextLabel.Text = "0" 
		script.Parent.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel.TextColor3 = Color3.new(0, 1, 0) 
	end
end
1 Like

This problem happens because for some reason, you added a check for whether or not Time would be 0. Time would of course be 0 though, because you made a timer that counts until 0.

Fixed code:

local TimeRemaining = script.Parent
local PlayerCount = TimeRemaining.Parent.Parent.Parent.Players.SurfaceGui.TextLabel
local OtherTextLabel = TimeRemaining.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel --//Rename OtherTextLabel to whatever it's called, you didn't specify what this was

while true do 
	for i = 29, 0, -1 do 
		task.wait(1) 
		TimeRemaining.Text = i 
	end

	if PlayerCount.Text ~= "0" then 
		workspace.Invwall.Size = Vector3.new(175, 25, 12)  --players cant enter the queue when teleporting
		OtherTextLabel.TextColor3 = Color3.new(0.4, 0, 0) 
		OtherTextLabel.Text = "TELEPORTING"
		
		task.wait(5) 
		workspace.Invwall.Size = Vector3.new(175, 25, 1)
		
		OtherTextLabel.Text = "READY"
		PlayerCount.Text = "0" 
		OtherTextLabel.TextColor3 = Color3.new(0, 1, 0) 
	end
end

I’ve also made your code more readable.

The OtherTextLabel was for the indicator to say “READY” and “TELEPORTING” depending on the conditions of the queue as stated below the TextColor3 line, but somehow this resolved the issue ty

I explained what the problem was here, it wasn’t the variable naming, I just did that for readability.

No, I believe it was the == index that you replaced with the ~=, that’s my only assumption but I’m not exactly sure

I was the one who fixed your code and I’m telling you what is wrong. That was just a change in how it was factored (which is not the bug that your code had).

Example:

This code:

if dog ~= 1 then
	print("Dog")
end

Runs the exact same as this code:

if dog == 1 then
	continue
else
	print("Dog")
end

The bug happened because you were checking if time was 0, and if it was, you didn’t start the teleportation sequence. Time would always be 0 when you checked though, because your timer counted down to 0.

Please read all of my replies before replying.

I’ll even write your code in the exact same way you did, and you can see that the problem was the time check.

Code:

while true do 
	for i = 29, 0, -1 do task.wait(1) 
		script.Parent.Text = i 
	end
	if script.Parent.Parent.Parent.Parent.Players.SurfaceGui.TextLabel.Text == "0" then continue else  --check the status
		game.Workspace.Invwall.Size = Vector3.new(175, 25, 12)  --players cant enter the queue when teleporting
		script.Parent.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel.TextColor3 = Color3.new(0.4, 0, 0) 
		script.Parent.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel.Text = "TELEPORTING"  
		wait(5) 
		game.Workspace.Invwall.Size = Vector3.new(175, 25, 1) script.Parent.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel.Text = "READY"
		script.Parent.Parent.Parent.Parent.Players.SurfaceGui.TextLabel.Text = "0" 
		script.Parent.Parent.Parent.Parent.guipart.SurfaceGui.TextLabel.TextColor3 = Color3.new(0, 1, 0) 
	end
end

Apparently I ran that code and yes it was the time check. Thanks for clarifying the everything, I’m not too experienced and sometimes I completely misunderstand things but thanks for your help. I really appreciate it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.