Tool parenting to workspace instead of the folder I created

  1. What do you want to achieve? I want this tool to be parented to the folder I created

  2. What is the issue? This tool keeps being parented to workspace instead of the folder I created

  3. What solutions have you tried so far? I’ve tried doing this PSA: Don’t use Instance.new() with parent argument - Updates / Announcements - DevForum | Roblox but it hasn’t solved anything. I also have tried changing the parent to workspace then to the folder

All I want is to make the Tool parent to the folder I created but it keeps parenting it to workspace.

function CreateItemFolder(player, itemName, toolInfo)
	local foundItemFolder = ItemsFolder:FindFirstChild(itemName)
	
	if foundItemFolder then
		local folder = Instance.new("Folder")
		folder.Name = itemName
		folder.Parent = workspace
		
		local toolClone = foundItemFolder.Tool:Clone()
		toolClone.Parent = folder
		
		local Configuration = Instance.new("Configuration")
		Configuration.Parent = folder
		
		for property, value in pairs(toolInfo) do
			if typeof(value) == "string" then
				local newValue = Instance.new("StringValue", Configuration)
				newValue.Name = property
				newValue.Value = value
			elseif typeof(value) == "number" then
				local newValue = Instance.new("NumberValue", Configuration)
				newValue.Name = property
				newValue.Value = value
			elseif typeof(value) == "boolean" then
				local newValue = Instance.new("BoolValue", Configuration)
				newValue.Name = property
				newValue.Value = value
			end
		end
		return folder
	end
end

I just found out that it is a roblox bug not a bug in my code

Might I ask what bug it is? The code seems about right

Roblox keeps parenting back to the workspace instead of keeping it parented to the folder

I just now tested it in my world and that doesn’t happen. This is the code I ran:

local tool = game:GetService("ReplicatedStorage"):WaitForChild("tool")

local folder = Instance.new("Folder")
folder.Name = tool.Name
folder.Parent = workspace

local clone = tool:Clone()
clone.Parent = folder

However I did notice that, if the tool spawns where the player spawns, then you’ll instantly pick it up. Maybe that’s what is causing it in your case? Let me know

No I found that my script was doing it. Sorry