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

How to make a clock count down?

AwayS = script.Parent.workspase
Clock = script.Parent.workspace
HomeS = script.Parent.workspace
LTeam = script.Parent.workspace
Quarter = script.Parent.workspace
RTeam = script.Parent.workspace

script.Parent.workspace.Function("Clock")
script.Parent.workspace = function "IsRunning"
if true then
	script.Parent.function = "IsRunning" than math. 5:oo subtract (1)
	
end

Is this right?

3 answers

You may need to do a loop like make 5:00 to seconds.

1 comment

0

Dang, that will take forever...

No, this is NOT correct, as this is NOT a working code! As your code is, it does not work. Let me point out the mistakes:

1. Lines 1-6 script.Parent.workspace? Is there an Instance within the scripts Parent named Workspace? If not, that's one problem, and not necessary to create so many identifiers that are doing the same purpose; It just uses up code-space.

2. Lines 8-9 script.Parent.workspace = Value? You are making those into Identifiers, and also attempting to make them functions, when you are doing it incorrectly.

3. Line 10 if true then? That will always run, because 'true' is, well, true, but, however, an if statement allows a block of code to run if it's Condition is equal/met to it's Argument, or if it equals true, you may want to rethink that part.

4. Line 11 script.Parent.function = Value? Your once again trying to create a function that will not work.

As your code is, it will not work. This is fixable however, but, I am not going to create a full script for you, just an example;

1. This will require a for loop

2. Also will require the wait method Now, let's rewrite your code;

for i = 5*60, 0, -1 do --Here is our four loop; This will begin it's time of 5*60, 5 minutes, or 250 seconds, will count down from -1, or down from 1, until identifier 'i' reaches 0; This will loop until 'i' reaches 0
print("Countdown:",i) --This will print into the Output; For each time 'i' goes down from '250', it will print the number into the Output; 'Countdown: 250', 'Countdown: 249', 'Countdown: 248', ect
wait(1) --This will wait 1 second before running the code again
end --This ends the code block for the 'for' loop

Hope this helped!

(I will use a gui for this one.) Put the gui in this way:

game
	StarterGui
			ScreenGui
					Frame
						TextLabel
								Sound --If you want!
								Script	

Script:

countdown = 0 --Put the time you want.

while true do
	script.Parent.Text = countdown
	countdown = countdown - 1
	wait(1) --This will disable lag.
end

if countdown == 1
	then script.Parent.Text = ("Times up!")
	script.Parent.Sound:Play() --If you do not have the sound remove this line or else this code will not work!
	script.Parent.Parent.Parent:remove() -- remove this line if you don't want it here.
end

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