You should use WaitForChild in LocalScripts when referencing Instances (in case they didn't load yet when you're trying to use them):
local sound = workspace:WaitForChild("Sound")
Because the script only runs on startup, the Sound probably won't be playing, that's because you have to listen for when it starts playing, with the Changed event:
local sound = workspace:WaitForChild("Sound")
local Fire = script.Parent:WaitForChild("Fire")
sound:GetPropertyChangedSignal("IsPlaying"):Connect(function()
while wait() do
if sound.IsPlaying then
local PlaybackLoudness = sound.PlaybackLoudness
Fire.Size = 0.5 - (PlaybackLoudness / 1000)
else
break
end
end
end)
By the way, the reason I'm using GetPropertyChangedSignal("IsPlaying") is because it's just a shorter replacement for
sound.Changed:Connect(function(PropertyName)
if PropertyName == "IsPlaying" then
end
end)
But, a simpler way of doing this is checking when the PlaybackLoudness itself changes, like this:
local sound = workspace:WaitForChild("Sound")
local Fire = script.Parent:WaitForChild("Fire")
sound:GetPropertyChangedSignal("PlaybackLoudness"):Connect(function()
local PlaybackLoudness = sound.PlaybackLoudness
Fire.Size = 0.5 - (PlaybackLoudness / 1000)
end)
Then, your particle's Size changes each time the PlaybackLoudness gets changed, without any inefficient loops
7 comments
Thanks, i'll try it now
I dont know why but its not working, its not showing any errors but its doing noting, maybe you can try it, still thanks for trying to get the answer maybe edit it later on. Reply to this if its working fine for you.
Did you :Play() the Sound?
Imma try doing that
not working
maybe we can try team create later on the day?
It looks like GetPropertyChangedSignal() doesn't work on the sound's PlaybackLoudness property, as well as IsPlaying and Playing. Might be a bug? I also noticed that I was only able to get GetPropertyChangedSignal() to work in a LocalScript. It might have to do with sounds in Workspace being played globally on every client, and not actually on the server.