Hello,
in this script I want to return a string from a function. After multiple testing I still couldn’t find out what was the issue. When I tested it I tried to see if it did go inside my if statements that only returns a simple string and it does but or some reason when I print out to see the results it just gives me a nil ? I am not using any remote function/event so I don’t know why it does this.
Here’s the function that returns
local function ContainsItem(returnItem, returnName)
local answer = "Plate"
for v,i in ipairs(FoodList) do
if Model:FindFirstChild(i) then
if returnName then return Model:FindFirstChild(i).Name end
return true
end
end
if returnItem then
--print(table.find(FoodList, Model:FindFirstChildWhichIsA('Tool'):GetChildren()[1]))
for v,i in ipairs(FoodList) do
if not Model:FindFirstChildWhichIsA('Tool') and not Model:FindFirstChild(i) then return false end
warn(Model:FindFirstChildWhichIsA('Tool'))
warn(#Model:FindFirstChildWhichIsA('Tool'):GetChildren() - 1)
if Model:FindFirstChildWhichIsA('Tool') and Model:FindFirstChildWhichIsA('Tool'):FindFirstChild('Handle') and #Model:FindFirstChildWhichIsA('Tool'):GetChildren() == 1 then return answer end
if Model:FindFirstChild('Clean_Plate'):FindFirstChild(i) then return true end
return false
end
end
end
Here’s the part where it’s handling it
local function TakeItem(plr)
local TempTool = ContainsItem(false, true)
print(TempTool)
end
The problem is at
if Model:FindFirstChildWhichIsA('Tool') and Model:FindFirstChildWhichIsA('Tool'):FindFirstChild('Handle') and #Model:FindFirstChildWhichIsA('Tool'):GetChildren() == 1 then return answer end
Which I verify even inside the if statement earlier that I did with a printing so logically it’s supposed to return the string value no?