My round system doesn't work I don't know why

Hi this is my first post on the devforum
I made a little local script that supposed to be a round system for my game
but it doesn’t work
Here is my code

local Time = game.ReplicatedStorage.Time
local timeText = game.ReplicatedStorage.TimerText
local textLabel = game.StarterGui.ScreenGui.TextLabel
local player = game.Players.LocalPlayer
Time.Value = 30
while true do
	wait(1)
	for i = Time, 0, -1 do
		timeText.Value = "game starts in "..i.."s"
		textLabel.Text = Time.Value
		if Time.Value == 0 then
			player.Character.PrimaryPart.Position = game.Workspace.Part.Position
			textLabel.Visible = false
			break
		end
	end
end

I tried everything please help
Also it Shows an error in the output
Workspace.LordBoboux.RoundSystem:6: invalid ‘for’ initial value (number expected, got Instance)

2 Likes

Wrong category.
As this is your first post, you don’t need to worry.

Please change the category to #help-and-feedback:scripting-support


Nope, wrong category again.
The category is Scripting Support.

1 Like

1-work with PlayerGui instead.
2- work with task.wait instead of wait
3- about the error:

change this into:

4 Likes

What about now? is that the correct catagory?

2 Likes

yes. thats the right category.

try what i suggested above and tell us if it works

1 Like

Hmmm it doesn’t show the error anymore but it doesn’t count down
the value isn’t changing

1 Like

what is the value of that value?

1 Like

Change the TextLabel.Text = Time.Value into TextLabel.Text = i

2 Likes

The value is 30 i have to make this longer because it only lets me post if it was long

1 Like

try:

local Time = game:GetService("ReplicatedStorage"):WaitForChild("Time")
local player = game:GetService("Players").LocalPlayer
local timeText = game:GetService("ReplicatedStorage"):WaitForChild("TimerText")
local textLabel = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel")

Time.Value = 30
while true do
	task.wait(1)
	for i = Time.Value, 0, -1 do
		timeText.Value = "game starts in "..i.."s"
		textLabel.Text = i
		if Time.Value == 0 then
			player.Character.PrimaryPart.Position = game.Workspace.Part.Position
			textLabel.Visible = false
			break
		end
	end
end
1 Like

I will try that too everything helps

1 Like

Nope that doesn’t work either what am i doing wrong?

1 Like

edited it. try now.

local Time = game:GetService("ReplicatedStorage"):WaitForChild("Time")
local player = game:GetService("Players").LocalPlayer
local timeText = game:GetService("ReplicatedStorage"):WaitForChild("TimerText")
local textLabel = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel")

Time.Value = 30
while true do
	task.wait(1)
	for i = Time.Value, 0, -1 do
		timeText.Value= i
		textLabel.Text = "game starts in "..i.."s"
		if Time.Value == 0 then
			player.Character.PrimaryPart.Position = game.Workspace.Part.Position
			textLabel.Visible = false
			break
		end
	end
end
1 Like

which one of them should be the number? while the other shows the text

1 Like

All that did was make the textlabel’s text to 0 but the time value isn’t changing

1 Like

Time is an intvalue its value is 30
while timeText is a string value

1 Like
local Time = game:GetService("ReplicatedStorage"):WaitForChild("Time")
local player = game:GetService("Players").LocalPlayer
local timeText = game:GetService("ReplicatedStorage"):WaitForChild("TimerText")
local textLabel = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel")


while true do
	task.wait(1)
	for i = 30, 0, -1 do
		timeText.Value= i
		textLabel.Text = "game starts in "..i.."s"
		if Time.Value == 0 then
			player.Character.PrimaryPart.Position = game.Workspace.Part.Position
			textLabel.Visible = false
			break
		end
       task.wait()
	end
end
1 Like

try debugging by using prints.
try printing and see what outcomes

1 Like

That did something really strange after run the game my camera get teleported but my character stays at spawn location and it all glitchy

1 Like

try-

local Time = game:GetService("ReplicatedStorage"):WaitForChild("Time")
local player = game:GetService("Players").LocalPlayer
local timeText = game:GetService("ReplicatedStorage"):WaitForChild("TimerText")
local textLabel = player:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("TextLabel")


while true do
	task.wait(1)
	for i = 30, 0, -1 do 
        print("done") -- print?
		timeText.Value= i
		textLabel.Text = "game starts in "..i.."s"
         print(timeText.Value) -- print?
		if Time.Value == 0 then
            print("done") -- print?
			player.Character.PrimaryPart.Position = game.Workspace.Part.Position
			textLabel.Visible = false
			break
		end
	end
end
1 Like