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

Counting script not doing anything. What's wrong?

So I have these scripts : LocalScript in StarterPack (My guess would be the errors here somewhere, but yet again the value in the severstorage never changes)

song1 = game.Soundscape.puzzle
player = game.Players.LocalPlayer
player.PlayerGui:WaitForChild("ScreenGui")
gui = player.PlayerGui.ScreenGui.TextLabel
seconds = game.ServerStorage.seconds.Value

seconds = 30
if game.ServerStorage.roundover.Value == true then
gui.Text = "Next game starts in ".. seconds .." seconds!"
repeat 
gui.Text = "Next game starts in ".. seconds .." seconds!"
wait(1)
until
seconds == 0
end

Script in ServerScriptService

seconds = game.ServerStorage.seconds.Value
puzzle = game.Soundscape.puzzle
game.ServerStorage.roundover.Value = true

seconds = 30
if game.ServerStorage.roundover.Value == true then
	puzzle:Play()	
	repeat 
	seconds = seconds - 1
	wait(1)
until
	seconds == 0
	puzzle:Stop()
end

game.ServerStorage.roundover.Value = false

wait(5)

game.ServerStorage.roundover.Value = true

I want these scripts to (if you can't read it) make a gui count down, nothing happens, no error in the output, the text doesn't change. What's wrong?

1 comment

1

Mind that it'll play play the sound and do the GUI stuff for only player 1, going from 30 to 0, then only player 2, going from 30 to 0, ... Maybe use a coroutine or spawn()

1 answer

I have a very simple script for you that works just fine! It even loops the song :) (or sound, your choice)

while true do
	wait(1)
	script.Parent.Sound:Play()
	wait(SOUNDLENGTH)
	wait(1)
end

If you do NOT want it to loop, do this:

roundStart = false

if roundStart == true then
	script.Parent.Sound:Play()
	wait(SOUNDLENGTH)
	roundStart = false
else
	wait()
end

4 comments

0

I don't need it looped, I just wanna know what's wrong and get a fix for it

0

I updated it. You will, of course, have to find a method to toggle roundStart to true

0

I want it to play the song while the counter counts down

0

Yes. Add a function that sets roundStart to true when the counter reaches 0

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