so basically how would i make an if statement check if a variables value is a certain value?
So if it was this script
local Food = Food
--Checks if foods value is food(where the if function goes)
I want to do this because i’m going to replicate the script and change a certain value so i want the script to go along with it since it will know what to do when it encounters it.
local myVar = "Test"
if myVar == "Test" then
--do stuff
else
--do stuff
end
local myVar = 6
if typeof(myVar) == "number" then
print("its a number!")
end
local cash = Player.leaderstats.Cash
if cash.Value >= 100 then
--do something
end
local Food = {"Watermelon","Banana","Burger"}
local Variable = "Coffee"
if table.find(Food,Variable) then
print("It's food!")
else
print("Not food!")
end
There is a way to shorten an if statement:
local myVal = false
local food = myVal == true and "is food" or "Not Food"
print(food)
(You can use _G.Var for global variables to use in multiple scripts).
local Number = 10
if Number % 2 == 0 then
print("even!")
else
print("odd!")
end