05:01:18.679 - Infinite yield possible on 'Workspace.Infl_uenced.UpperTorso:WaitForChild("Small Backpack")'
although it does in fact exist in uppertorso?
heres whats on line 96 (Where the error occurs)
if GoldAmount.Value >= Item.ItemPrice.Value then
if player.UserStats.OwnedBackpack.Value ~= Item then
local Character = player.Character
local backpack = Item.ItemName.Value
if oldBag ~= nil then
Character["UpperTorso"]:WaitForChild(oldBag) -- the specified line which it occurs on
Character["UpperTorso"][oldBag]:Destroy()
end
local backpackPart
if game.ReplicatedStorage.BackpackLib:FindFirstChild(backpack) then
print('found backpack')
backpackPart = game.ReplicatedStorage.BackpackLib[backpack]:Clone()
else
print(backpack)
end
backpackPart.CanCollide = false
backpackPart.Parent = Character["UpperTorso"]
local Weld = Instance.new("Weld", backpackPart)
Weld.Part0 = Character["UpperTorso"]
Weld.Part1 = backpackPart
if backpack == "Starter Backpack" then
Weld.C1 = CFrame.new(0, -.2, .5) * CFrame.Angles(0,math.pi,0)
else
Weld.C1 = CFrame.new(0, .2, -.5)
end
GoldAmount.Value = GoldAmount.Value - Item.ItemPrice.Value
player.UserStats.OwnedBackpack.Value = Item.ItemName.Value
player.UserStats.OwnedBackpackStorage.Value = BackpackModule["BackpacksData"][Item.ItemName.Value][1]

5 comments
The script is probably loading in before the object does. You can instead use FindFirstChild() as a debug.
I doubt that's the issue as this doesnt happen until you click a button ~
can you print oldBag before of waiting for it?
Is this a local or server script?
@RobloxWhizYT it's a server script, for when a remoteevent is called