Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

My script doesnt work correctly when my player spawn?

Hello, I have this problem.

-- Declaraciones --
guicontrol = game.StarterGui.Informacion.marco.texto
lobby = game.Workspace.Juego.Lobby
audio1 = lobby.Decoracion.Maquina.Part

-- Puesto de control --

-- Sistema del juego --
while true do
	for i = 30,1,-1 do
		print(i)
		guicontrol.Text = "El juego comenzara en "..i.." segundos."
		wait(1)
		if i == 1 then
			guicontrol.Text = "Eligiendo mapa..."
			wait(5)
			guicontrol.Text = "Mapa elegido:"
			wait(5)
		end
	end
end

This script works fine, I tried everything to find the error but nothing. When my player shows up the in-game counter stops but the console keeps printing 30..29..28..27 ... if I restart my player the counter is automatically updated and freezes again... I dont know what is happening and why?

2 comments

0

Get rid of the while true do() loop

0

I need to repeat it permanently. and I tried it and dont work.

1 answer

✓ Accepted answer

For the module script: Make a string value in Replicated Storage and name it "Status". Put the module script in ServerScriptService

local module = {}
		
	module.Intermission = function(length)
		local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")
		
		for i = length, 0, -1 do 
			
			Status.Value = "Intermission: "..i.." seconds left"
			
			wait(1)
			
		end
	end
	
	
	module.Round = function(length)
		local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")	
		
		for i = length, 0, -1 do
			
			Status.Value = "Round in Progress: "..i.." seconds left"
			
			wait(1)
			
		end
	end
return module







--Server Script


local RoundModule = require(script.Parent.Module)


while true do
	
	RoundModule.Intermission(30) --This is the amount of time you want your intermission to be
	wait()
	RoundModule.Round(150) --This is the amount of time you want your Round to be.
	
end



--Now insert a ScreenGUI in StarterGUI and insert a TextLabel and customize it however you want. Name the TextLabel "RoundGUI". Insert a local script in the ScreenGUI.

--Local script


local Status = game:GetService("ReplicatedStorage"):WaitForChild("Status")

local RoundGUI = script.Parent:WaitForChild("RoundGUI")


Status:GetPropertyChangedSignal("Value"):Connect(function()

	RoundGUI.Text = Status.Value

end

And that is all!

Remember you can always edit the script to add more text for your round that suits your game.

13 comments

1

The way I did my Round system is that I did it in a module script and made two different functions and in a server-side script, I made a while loop so it repeats. And then I made a String value for the for loop to update. Just contact me back if you want me to show you my script, it hard to explain.

0

Okay thank you for your support, I will contact you if is something wrong!

0

Okay, no problem!

0

Okay I need help with that module script, its hard to understand that :/

0

Okay!

0

Alright, that was my final edit in the script. It is all yours now!

0

Thank you dude!

0

Don't sweat it!

0

XD god damnn works too but the gui didnt update. Are you sure that im wrong? The console still printing 30..29..28.. what if my roblox studio is not working correctly?

0

This is my script now: https://justpaste.it/78ugs

0

Make sure to put the script in the ScreenGUI and just do script.Parent instead of game.StarterGUI because everthing is copied from StarterGUI to the PlayerGUI. So put the script in the ScreenGUI and just do script.Parent.RoundGUI

0

Okey the mistake was about game.StarterGUI thank you so much. Solved.

0

No problem.

This discussion is preserved as it was. New answers, comments, and votes are closed.