I’ve created a script that allows the player to pick up an item when it’s clicked and a unit with a clickdetector that the player should be able to click in order to put down that item. The player can pick up 3 items so far, they’re named Apple, Banana and Kiwi but unfortunately Kiwi is lame and I don’t want it to be allowed to go on the units. So that leads to my question how would I create a list of items that CAN go on the unit that should be checked using an If statement? Could I have a table with the names of items that can be placed on the unit?
local whitelist = {"Apple", "Banana"}
if table.find(whitelist, item.Name) then
--
end
something like this
2 Likes
How would I use this to check parts inside a model? I want to check if a model contains any of the items in the whitelist.
local Whitelist = {"Apple", "Banana"}
for Index, Value in pairs(Model:GetDescendants()) do
if table.find(Whitelist, Value.Name) then
--
end
end
2 Likes