Hi, this should be simple, i have asked on 3 discord, and googled.
I am just trying to compare two 'strings' that are items in backpack or from data store, so that I can set it to false, and not have the player get two of the same items added back info their backpack. Like two of the same swords. , in this case , the item is called 'GalaxyGilder'
The code sees what was in datastore, then compares it to what is already in the backpack. In this case, it has added one 'GalaxyGlider' to the backpack, and the code is now looking to see if it should add another one, which is where I am trying to get the string compare to be false.
do you know how to compare to scripts to check if they are the same, if one of them is a table variable?
simple string compare help
I have tried 3 ways to compare a two strings, but it is always false
here is the output
03:34:34.468 this is the var i =3
03:34:34.469 this is the var tool to compare =
03:34:34.436 GalaxyGlider
03:34:34.469 this the the var new bracket i = backpack item name
03:34:34.436 GalaxyGlider
03:34:34.470 false
03:34:34.470 false
03:34:34.470 var wasitfound=
03:34:34.470 false
03:34:34.470 false
03:34:34.470 var wasitfound=
03:34:34.471 false
03:34:34.471 var wasitfound2 =
03:34:34.471 false
print (tool == new[i])
07 | print ( crap 1 = = crap 2 ) |
09 | if [[ "crap1" ]] = = [[ "crap2" ]] |
10 | then wasitfound = true |
12 | print ( "var wasitfound=" ) |
15 | print ( crap 1 = = crap 2 ) |
tool = GalaxyGlider
new[i] = GalaxyGlider
but they all comeback as false, when I need it to come back as true, and ugg
thanks please AT me if you know why
--another way
local str1 = tool
local str2 = new[i]
local wasitfound2 = false
--local function stringMatch(str1, str2)
local function stringMatch(str1, str2)
if type(str1) == "string" and type(str2) == "string" then
if string.len(str1) >= string.len(str2) then
local subString = string.sub(str1, 1, string.len(str2))
if subString == str2 then
wasitfound2 = true
return str1
end
end
else
return error("Parameters must be strings")
end
end
print ("var wasitfound2 =")
print(wasitfound2)
the compare of the strings are always coming back false
more info on my issue :
ServerScriptService.toolSave:57: attempt to call a table value
when I did
local crap2 = string(new[i])
so i guess my issue is that, so how do i assing a variable to that table value
LordBradyRocks!Today at 4:07 AM
or it is still the compare that is false for some reason
i did this and it does not error out, but the compare is still false
local crap2 = print(new[i])
note new[i] GalaxyGlider , are items in Backpack
Note tool is set up as
local tool = library:FindFirstChild(list[i])