If statement for value not working

Issue I am having is that when the value is not Honda or Jeep or BMW it still prints the value and warn(“Cars”).

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
	local val = game.Workspace.Value
	if val.Value == "Honda" or "Jeep" or "Bmw" then
	print(val.Value)
		warn("Cars")

Probably because your string value that’s in the workspace is either Honda, jeep or bmw.

I checked and its either set to a different car or has no value
also it prints gmc
Screen Shot 2023-07-27 at 5.58.56 PM

Oh I can see the problem. You’re doing this:

if val.Value == "Honda" or "Jeep" or "Bmw" then

When you should be doing this:

if val.Value == "Honda" or val.Value == "Jeep" or val.Value == "Bmw" then

Lua automatically sees all strings as true, so you need to check the value for every car.

3 Likes

Thank you for all your help!! :grinning:

1 Like

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