For pairs loop ignoring if - then statement

Beginner here, working on a modulescript that has a function to add sounds with additional parameters.
I’ve been trying to understand the difference between this conditional check in a pairs loop, where “i” is a dictionary of optional configuration values, like Volume, sent to the function. The script runs perfectly as it should when using the following code,

if i == "Weld" then
		local NewWeld = Instance.new("WeldConstraint")
		NewWeld.Parent = PartClone
		NewWeld.Part0 = PartClone
		NewWeld.Part1 = v
	end
	
	if i == "Volume" then
		SoundClone[i] = v
	end
	
	if i == "PlaybackSpeed" then
		SoundClone[i] = v
	end
	
	if i == "Looped" then
		SoundClone[i] = v
	end
	
	if i == "TimePosition" then
		SoundClone[i] = v
	end
	
	if i == "Lifetime" then
		Debris:AddItem(PartClone, v)
	else
		Debris:AddItem(PartClone, PartClone:FindFirstChild("Sound").TimeLength * 1.5)
	end
end

But obviously, with the middle section, checking each value individually and then doing the exact same thing is ugly and repetitive. Originally, I tried to run the following code;

if i == "Volume" or "Looped" or "TimePosition" or "PlaybackSpeed" then
	SoundClone[i] = v
end

The problem is that any time the loop reaches the if - or - then statement for the 4 values above, the index seems to ignore the conditional and just runs through the following code anyways, breaking the script when it tries to change “Weld” as a property of a Sound instance. I have been trying to find what I’m doing wrong for like 4 hours now, and its killing me because it seems so simple. I think I am just misunderstanding something about the “or” conditional.

Thank you!

1 Like

this is because you need another pair of i == for each or.

if i == "Volume" or i == "Looped" or i == "TimePosition" or i == "PlaybackSpeed" then
	SoundClone[i] = v
end
3 Likes

Thank you so much, I knew it was something stupid and simple like that.