but at the end, it clearly says “tool.Parent = plr.Backpack”
ITEMS ARE PRINTED AT THE FOR LOOP
for i,veee in pairs(plr.Backpack:GetChildren()) do
print(veee.Name .. ' is in backpack')
end
NOTHING IS IN THE BACKPACK. HELP PLEASE I BEEN WORKING ON THIS FOR 5 DAYS
AND FOR SOME REASON THIS WORKS ON ROBLOX STUDIO BUT NOT ROBLOX
if data['ItemTable'] then
print('ItemTable is not nil')
for i,v in ipairs(data['ItemTable']) do
local foods = game.ReplicatedStorage.food:GetChildren()
print('Checkinggfood for loop')
print(v)
for i,food in pairs(foods) do
print(food.Name)
print('Entering food for loop')
print(v.. '. Comparison: ' .. tostring(food.Name))
if v == food.Name then
print('creating tool')
local tool = Instance.new('Tool')
local itemclone = food:Clone()
tool.Name = food.Name
itemclone.Name = "Handle"
itemclone.Parent = tool
itemclone.Anchored = false
tool.Parent = plr.Backpack
itemclone.take:Destroy()
itemclone.Parent = tool
module.ItemUse(itemclone.LuckBooster.Value, tool, itemclone.Time.Value, plr)
for i,veee in pairs(plr.Backpack:GetChildren()) do
print(veee.Name .. ' is in backpack')
end
-- itemclone.Position = plr.Character.HumanoidRootPart.Position
end
end
end
else
print('its nil rn')
end
why dont you drag your tools in replicatedStorage and then cloning it into your starterpack heres the script:
local tools = game.ReplicatedStorage.tools --Defining the tools in replicatedstorage
tools:Clone() --Cloning tools into starterpack
tools.Parent = game.Starterpack
for i,v in ipairs(data['ItemTable']) do
local foods = game.ReplicatedStorage.food
local tools = foods.tools
print('Checkinggfood for loop')
print(v)
for i, tool in pairs(tools:GetChildren()) do
if tool.Name == v then
local newtool = tool:Clone()
newtool.Parent = plr.Backpack
end
end
end