If statement seems to let everything through

Hi, I’m trying to loop through workspace and find any parts of the name “demoblock” or “demodeleteblock”, and after checking that the localplayer (this is a LocalScript) owns the part (ownership is kept by using a StringValue named Owner), the part is deleted.

However for some reason, the v.Name check just accepts everything?

for i, v in pairs(workspace:GetChildren()) do
	if v.Name == "demoblock" or "demodeleteblock" then --This lets everything through?
		if v.Owner.Value == player.Name then
			v:Destroy()
		end
	end
end

image
Of course Owner isn’t a valid member of Camera, but Camera I believe shouldn’t even be checked for Owner. Adding [and v.Name ~= “Camera”] only lets the next thing in workspace through.

help would really be appreciated

1 Like

The issue you have is within your if statement.
You have the line:

if v.Name == "demoblock" or "demodeleteblock" then

Instead, you should rewrite it as:

if v.Name == "demoblock" or v.Name == "demodeleteblock" then

Using the ‘or’, a seperate condition is being stated. So the code was recognising the condition “demodeleteblock” seperately with an “or”. This string alone will always return true, as it is not null.

1 Like

ohhhh my bad I realize that now. Thank you

1 Like