Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

could you turn the items folder into specific items…

  1. User

    could you turn the items folder into specific items foldergame.Players.PlayerAdded:Connect(function(plr)

    local items = Instance.new("Folder")
    
    plr.CharacterAdded:Connect(function(char)
    	local hum = char:FindFirstChild("Humanoid")
    	for i, v in pairs(items:GetChildren()) do
    		v.Parent = plr.Backpack
    	end
    	hum.HealthChanged:Connect(function()
    		if hum.Health <= 0 then
    			if char:FindFirstChildOfClass("Tool") then
    				char:FindFirstChildOfClass("Tool").Parent = items
    			end
    			for i, v in pairs(plr.Backpack:GetChildren()) do
    				v.Parent = items
    			end
    		end
    	end)
    end)
    

    end)

  2. Assistant

    Sure! Here's the code with the "items" folder turned into "specificItems" folder:

    game.Players.PlayerAdded:Connect(function(plr)
    	local specificItems = Instance.new("Folder")
    	
    	plr.CharacterAdded:Connect(function(char)
    		local hum = char:FindFirstChild("Humanoid")
    		for i, v in pairs(specificItems:GetChildren()) do
    			v.Parent = plr.Backpack
    		end
    		hum.HealthChanged:Connect(function()
    			if hum.Health <= 0 then
    				if char:FindFirstChildOfClass("Tool") then
    					char:FindFirstChildOfClass("Tool").Parent = specificItems
    				end
    				for i, v in pairs(plr.Backpack:GetChildren()) do
    					v.Parent = specificItems
    				end
    			end
    		end)
    	end)
    end)
    

    Now, when a player joins, the script will create a new folder called "specificItems" instead of "items".