Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Sound play back loudness won't work?

Asked by 8 years ago
Edited 8 years ago

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)
0
Can you post the code? User#5423 17 — 8y
0
PlaybackLoudness only works in LocalScripts. adark 5487 — 8y
0
I put this code in a local script and it didn't do anything Exanimatedn9dean 37 — 8y

1 answer

Log in to vote
1
Answered by
mnaj22 44
8 years ago

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.

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. Exanimatedn9dean 37 — 6y
Ad

Answer this question