Sound not playing

  1. What do you want to achieve? Explosion sound

  2. What is the issue? Sound not playing

  3. What solutions have you tried so far? Checkiking playback loudness, no

here script:

local min = 0
local seconds = 30
local mic = 0
while wait(.09) do
	mic -= 1
	if mic < 0 then
		seconds -= 1
		mic = 9
	script.Parent.Text = min..":"..seconds.."."..mic
	if seconds < 10 then
		script.Parent.Text = min..":0"..seconds.."."..mic
	if seconds == 0 and mic == 0 then
		seconds = 0
		mic = 0
		script.Parent.boom.Disabled = false
		workspace.In.Value = 1500

1 Like

This script seems very overly complicated. What are you trying nto do exactly with mic and seconds.

There are some ??!! part in it too.


What exactly is your logic?

1 Like

Subtracting them, it’s like a timer.

1 Like


Well there is actually an Open Sourced Timer Module on Roblox Devhub Here it is if you want it
If you want it here it is.

This text will be hidden

local Timer = {}
Timer.__index = Timer
	local self = setmetatable({}, Timer)
	self._finishedEvent ="BindableEvent")
	self.finished = self._finishedEvent.Event
	self._running = false
	self._startTime = nil
	self._duration = nil
	return self
function Timer:start(duration)
	if not self._running then
		local timerThread = coroutine.wrap(function()
			self._running = true
			self._duration = duration
			self._startTime = tick()
			while self._running and tick() - self._startTime < duration do
			local completed = self._running
			self._running = false
			self._startTime = nil
			self._duration = nil
		warn("Warning: timer could not start again as it is already running.")
function Timer:getTimeLeft()
	if self._running then
		local now = tick()
		local timeLeft = self._startTime + self._duration - now
		if timeLeft < 0 then
			timeLeft = 0
		return timeLeft
		warn("Warning: could not get remaining time, timer is not running.")
function Timer:isRunning()
	return self._running
function Timer:stop()
	self._running = false
return Timer

Otherwise You might benefit by making your code more modular. Also, tip instead of hardcoding things like this

if mic < 0 then
	seconds -= 1
	mic = 9

We can use maths to work out it instead. This makes it easily expandable and readable too.

The operators we are going to use is the /, math.floor and the % operators
The / and floor gets the integer division from the two numbers like this

math.floor(7 / 3) -- Answer is 2

and the modulo or % operator gets the remainder

7 % 3 -- Answer is 1

We can combine these two operators to convert minutes into minutes and hours or milliseconds into seconds and milliseconds. Like this

local MINUTE_LENGTH = 60
local Time = 371 -- Let's say we have this much time left measured in seconds
local Minutes = Time % MINUTE_LENGTH
local Seconds = math.floor(Time / MINUTE_LENGTH)

Voila :slight_smile: To change to work with milliseconds simply change the duration of the divisor to whatever you want to convert from e.g. Hours>Days = 24 Milliseconds>Seconds = 1000.

Format strings

There is also a better way to do this too. String Formatting! more info can be found here

local str = "%02i" --This will be what you can use to format a string to always be 2 spaces
print(string.format(str, 5)) -- prints 05

So, we can do this instead.

local Seconds = 4
local Minutes = 3
local Hours = 10
local stringFormat = "%02i"
local String = string.format(str,Hours)..":"..string.format(str,Minutes)..":"..string.format(str,Seconds) -- Change it to how you would like to change it to.

Wait and RunService

There are numerous articles about this but just to say it is better to use RunService for these types of things instead of using wait() and wait(x) where x is a small number. Not only does it give you a parameter for the amount of time it is running but it is also faster

    -- Code here
-- or
local RunService = game:GetService("RunService")
while RunService.Stepped:Wait() do
    -- Code here

I have looked at your script and I am not sure what would be causing the problem. Hopefully I haven’t confused you and by implementing these changes you will be able to find the problem.

If you are still having trouble reply.