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

Sound play back loudness won't work?

I made a head with a mouth that moves to the loudness of a sound, it works in studio, but why in online servers does it return NAN?

Script inside part called 'mouth'

local cp = game:GetService("ContentProvider")
cp:Preload("rbxassetid://143736517")
wait(5)
local p = script.Parent.Mesh
local e1 = script.Parent.Parent.Eye1
local e2 = script.Parent.Parent.Eye2
local s = script.Parent.Sound
local h = script.Parent.Parent.Head
local sc = h.Mesh.Scale

math.randomseed(tick())
coroutine.wrap(function()
	while wait(math.random(1,7)) do math.randomseed(tick())
		for i = 1, 10 do wait(1/60)
			e1.Mesh.Scale = e1.Mesh.Scale-Vector3.new(0,0.1,0)
			e2.Mesh.Scale = e1.Mesh.Scale
		end
		for i = 1, 10 do wait(1/60)
			e1.Mesh.Scale = e1.Mesh.Scale+Vector3.new(0,0.1,0)
			e2.Mesh.Scale = e1.Mesh.Scale
		end
	end
end)()

local deb = false
local debbing = false
script.Parent.Parent.Head.Touched:connect(function()
	if deb == false and debbing == false then deb = true debbing = true
		s:Stop()
		wait(2)
		debbing = false
	elseif deb == true and debbing == false then deb = false debbing = true
		s:Play()
		wait(2)
		coroutine.wrap(function()
			while wait(1/60) do if s.Playing == false then break else
					if s.PlaybackLoudness > 498 then
						h.BrickColor = BrickColor.new("Institutional white")
						h.Mesh.Scale = h.Mesh.Scale+Vector3.new(1,0.3,1)
						h.Material = "Neon"
						h.PointLight.Enabled = true
					elseif s.PlaybackLoudness < 498 then
						h.Mesh.Scale = sc
						h.BrickColor = BrickColor.new("Light orange")
						h.Material = "Plastic"
						h.PointLight.Enabled = false
					end
					p.Scale = Vector3.new(1,s.PlaybackLoudness/100,s.PlaybackLoudness/100)
				end
			end
		end)()
		wait(2)
		debbing = false
	end
end)

3 comments

0

Can you post the code?

0

PlaybackLoudness only works in LocalScripts.

0

I put this code in a local script and it didn't do anything

1 answer

✓ Accepted answer

I had this same problem before too. I fixed it by putting the sound in the PlayerGui and making the script a local script. If you want everyone in the server to see the mouth moving without it glitching out I would recommend turning on filtering enabled too.

1 comment

0

lol I'm 1 year late, had forgotten about scripting helpers for a while. I've gotten a lot more experience in scripting than what I once had at the time of posting this question by now.

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