Help with if statement

Even when text isn’t set to “Off”/“Muted” etc it will not turn red and simply stays green, not sure why

	local Button = script.Parent:WaitForChild(ItemValue):WaitForChild("Button")
	local Title = script.Parent:WaitForChild(ItemValue):WaitForChild("Title")
	local Stroke = Button:WaitForChild("UIStroke")
	local Gradient = Button:WaitForChild("UIGradient")
	local Shadow = Button:WaitForChild("DropShadow")
	local funccheck = 0
	
	local tween_A = tweenService:Create(Title, tweenInfo_A, {TextColor3 = Color3.fromRGB(255, 255, 255)})
	
	if Button:WaitForChild("TextLabel").Text == "Off" or "Muted" or "Paused" or "False" or "No" then
	local tween_Ba = tweenService:Create(Shadow, tweenInfo_B, {ImageColor3 = Color3.fromRGB(26, 255, 0)})
	local tween_Ca = tweenService:Create(Stroke, tweenInfo_B, {Color = Color3.fromRGB(43, 255, 28)})
	Gradient.Color = colorSequenceGreen
	tween_Ba:Play()
	tween_Ca:Play()
	funccheck = funccheck+3
	else
	local tween_Bb = tweenService:Create(Shadow, tweenInfo_B, {ImageColor3 = Color3.fromRGB(244, 45, 18)})
	local tween_Cb = tweenService:Create(Stroke, tweenInfo_B, {Color = Color3.fromRGB(255, 103, 43)})
	Gradient.Color = colorSequenceRed
	tween_Bb:Play()
	tween_Cb:Play()
	funccheck = funccheck+3
	end
1 Like
Text = "Item 3"
if Text == "Item 1" or "Item 2" then
  -- This would always print since you're not comparing "Item 2" to anything
  print("Valid item")
end
Text = "Item 3"
if Text == "Item 1" or Text == "Item 2" then
  -- This wouldn't print
  print("Valid item")
end

so either you could check the text for each string

if Text == "Off" or Text == "Muted" or Text = "Paused" ... then

end

or your could make an options array and search for the text using table.find()

local Options = {"Off", "Muted", "Paused", "False", "No"}
if table.find(Options, Text) then

end
1 Like

Oh i understand now, just changed up some of my code and it works perfectly.

Thanks for the help/feedback! :blush:

1 Like

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