Something wrong on line 24?

All of the code is working fine, it’s just on line 24 that gives me an error. It reads, “Value is not a valid property name.” and I even checked it with :IsA()

The code (ignore first 2 code blocks):

wait(0.1)
local Hum = script.Parent.Humanoid

Hum.Died:Connect(function()
	script.Parent.Head.Vocal.Volume = 0
end)

script.Parent.Ragdolled:GetPropertyChangedSignal("Value"):Connect(function()
	if script.Parent.Ragdolled.Value == true then
		local ScreamSoundSFXs = Hum.RootPart.ScreamSFX:GetChildren()
		local RandomScr = ScreamSoundSFXs[math.random(1, #ScreamSoundSFXs)]
		
		script.Parent.Head.Vocal.SoundId = RandomScr.SoundId
		script.Parent.Head.Vocal:Play()
	end
end)


for i, child in ipairs(script.Parent:GetDescendants()) do
	child:GetPropertyChangedSignal("Value"):Connect(function()
		if child:IsA("IntConstrainedValue") then
			if child.Value == 0 then
				local ScreamSoundSFXs = Hum.RootPart.ScreamSFX:GetChildren()
				local RandomScr = ScreamSoundSFXs[math.random(1, #ScreamSoundSFXs)]
				
				script.Parent.Head.Vocal.SoundId = RandomScr.SoundId
				script.Parent.Head.Vocal:Play()
			end
		end
	end)
end

Any help would be appreciated.

Does this work?

wait(0.1)
local Hum = script.Parent.Humanoid

Hum.Died:Connect(function()
	script.Parent.Head.Vocal.Volume = 0
end)

script.Parent.Ragdolled:GetPropertyChangedSignal("Value"):Connect(function()
	if script.Parent.Ragdolled.Value == true then
		local ScreamSoundSFXs = Hum.RootPart.ScreamSFX:GetChildren()
		local RandomScr = ScreamSoundSFXs[math.random(1, #ScreamSoundSFXs)]
		
		script.Parent.Head.Vocal.SoundId = RandomScr.SoundId
		script.Parent.Head.Vocal:Play()
	end
end)


for i, child in ipairs(script.Parent:GetDescendants()) do
	if child:IsA("IntConstrainedValue") then
		child:GetPropertyChangedSignal("Value"):Connect(function()
			if child.Value == 0 then
				local ScreamSoundSFXs = Hum.RootPart.ScreamSFX:GetChildren()
				local RandomScr = ScreamSoundSFXs[math.random(1, #ScreamSoundSFXs)]
				
				script.Parent.Head.Vocal.SoundId = RandomScr.SoundId
				script.Parent.Head.Vocal:Play()
			end
		end)
	end
end

infinite yield may be possible, havent tested it though.

1 Like

It works just fine, thank you so much!