Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I check if a value is in a table?

What I want to do is repeat the RemoteEvent until the CurrentFruit is equal to one of the Fruits in the table. How do I do that?

local fruits = {"Apple", "Orange", "Pineapple"}
local eatevent = game:GetService("ReplicatedStorage").EatEvent
local plr = game.Players.LocalPlayer
local currentfruit = plr.Data.Fruit

repeat
    eatevent:FireServer()
until
currentfruit.Value:lower() == fruits:lower()

1 answer

✓ Accepted answer

using table.find(table,value)

so from line 6 to 9, do this:

repeat
	eatevent:FireServer()
until
table.find(fruits,currentfruit.Value)

more abt tables

6 comments

0

is there any way i could use :lower() on table.find?

0

i don't see a function called :lower(), what is it?

0

its to make strings lowercase for example if i did local text = "WORD" print(text:lower()) then the output would be "word"

0

oh, it is string.lower(text)

0

however i suggest just changing the uppercases in the table to be lower case >.> and then changing currentfruit.Value into string.lower(currentfruit.Value)

0

thank you very much for telling me!

This discussion is preserved as it was. New answers, comments, and votes are closed.