Problem with if statements

I have a problem with if statements, I wrote these two scripts and they work fine

local EW1D = game.Workspace.easywall1.Decal
local EW1 = game.Workspace.easywall1

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if msg == "Shelly" or "shelly" then
			EW1.Transparency = 0.7
			EW1D.Transparency = 0.7
			EW1.CanCollide = false
			wait(3)
			EW1.Transparency = 0
			EW1D.Transparency = 0
			EW1.CanCollide = true
		end
	end)
end)
local EW2D = game.Workspace.easywall2.Decal
local EW2 = game.workspace.easywall2

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if msg:lower() == "colt" then 
			EW2.Transparency = 0.7
			EW2D.Transparency = 0.7
			EW2.CanCollide = false
			wait(3)
			EW2.Transparency = 0
			EW2D.Transparency = 0
			EW2.CanCollide = true
		end
	end)
end)

but when I wrote the 3rd script:

local EW3D = game.Workspace.easywall3.Decal
local EW3 = game.workspace.easywall3

game.Players.PlayerAdded:Connect(function(player)
	player.Chatted:Connect(function(msg)
		if msg:lower() == "nita" then 
			EW3.Transparency = 0.7
			EW3D.Transparency = 0.7
			EW3.CanCollide = false
			wait(3)
			EW3.Transparency = 0
			EW3D.Transparency = 0
			EW3.CanCollide = true
		end
	end)
end)

when I say nita, the EW3 and EW1 BOTH disappear, for some unknown reason. Can anyone help me please?

This is the error. You don’t correctly use the or operator.

if msg == "Shelly" this is corect
or "Shelly" This does not check if msg == “Shelly”. It will always interpret as true.

Fix it by doing this:
if msg == "Shelly" or msg == "shelly" then

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.