I want to make a object that when it gets close to a part with a certain name it plays an audio, the thing is that I want multiple parts to be around the map and have the object play the audio whenever it's around the part. I don't really know how to explain it well but basically I need some help with the getchildrenw which gets stuff from a folder in workspace. Here's the code. Thanks for viewing C:
while true do local partfind = game.Workspace.TestSound:GetChildren() local nfs = (script.Parent.Position - partfind.partSound.Position).magnitude ----The coding under this text is fine---- if nfs <= 10 then script.Parent.Soundl1.PLFFF.Disabled = false script.Parent.Soundl1.PLFFF2.Disabled = true wait() end if nfs >= 9 then script.Parent.Soundl1.PLFFF.Disabled = true script.Parent.Soundl1.PLFFF2.Disabled = false wait() end wait() end
Have you maybe tried using loops to check the condition with each object with that name?
for _, v in pairs(partfind) do if v.Name == "partSound" then local nfs = (script.Parent.Position - v.Position).magnitude if nfs <= 10 then ... end end
Hope this helped