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)
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.