Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

infinite yield on something that exists?

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

0

The script is probably loading in before the object does. You can instead use FindFirstChild() as a debug.

0

I doubt that's the issue as this doesnt happen until you click a button ~

0

can you print oldBag before of waiting for it?

0

Is this a local or server script?

0

@RobloxWhizYT it's a server script, for when a remoteevent is called

1 answer

So I ended up figuring it out my own after sitting down and attempting to debug the situation heres what I found (be aware this might not be the most efficient way of doing so)

Apparently, the server does not update anything added into bodyparts so you'll have to use fireclient instead and delete it from there :)

This discussion is preserved as it was. New answers, comments, and votes are closed.