Localscript completely ignoring parts

Hello there,

I’m having an issue with my local script completely ignoring parts in a folder for seemingly no reason.

The script works in other games but just not in mine.

Here is my set up:

image

image

and here is the script:

local ss = script.SoundwaveFolder.Value
local sds = ss.Sounds
local c = ss.Current

print(ss:GetChildren())

function fadeIn(x)
	x:Play()
	for y = 0,1,0.05 do
		x.Volume = y
		wait()
	end
end

function fadeOut(x)
	for y = 1,0,-0.05 do
		x.Volume = y
		wait()
	end
	x:Stop()
end

for i, v in pairs(ss:GetChildren()) do
	if v:IsA("BasePart") then
		v.Touched:Connect(function(x)
			if x.Parent:FindFirstChild("Humanoid") then
				if c.Value ~= v then
					c.Value = v
					for i, a in pairs(sds:GetChildren()) do
						if a.Playing == true then
							fadeOut(a)
						end
					end
					fadeIn(v.SoundToUse.Value)
				end
			end
		end)
	end
end

Any ideas as to what I’m doing wrong?

2 Likes

The only thing it could be is you might’ve inputted the wrong folder for the SoundwaveFolder’s value. Do you get any errors when trying to use this? Maybe add print statements around in your code, especially in the pairs loop to see what’s happening exactly

Nope, 0 errors whatsoever.

image

I printed out the contents of the folder and received this.

The bricks are anchored and are solid so they aren’t falling through the ground.

When indexing the parts to the variable use :WaitForChild() as often on client especially when using StreamingEnabled properties the script will load before the parts do resulting in them being nil

2 Likes

Perhaps it could be what @Send_Scripts stated? Try adding a small delay such as wait(2) before the main code and see if the parts are seen? If they do get seen, you can probably wait until the player’s character is added instead

1 Like

If its a matter of parts missing, due to streaming, I would change that sound system folder to a model, and then disable Streaming on the performance attribute of the model.

You can use a plugin to change the SoundSystem class from Folder to Model, to achieve this.

A few blocks (or even several) for sound, probably should be included in the streaming capabilities of a map, anyway. I typically disable streaming for spawn points and important parts/meshparts of a map that need to be indexed in my scripts in order to avoid breaking the game play.

Disable streaming on the performance attribute of the model…?

I’m pretty sure thats… not a thing.